码迷,mamicode.com
首页 > 数据库 > 详细

数据库中解析XML

时间:2016-08-05 12:00:58      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:

简介:OPENXML方法使用一例实现导入功能

DECLARE @strProjGUID AS VARCHAR(50)
  DECLARE @strProjCode AS VARCHAR(50)
  DECLARE @idocImpXml AS INT
  DECLARE @xmlCount AS INT
  DECLARE @i  AS INT     
  DECLARE @m  AS INT 
 
  DECLARE @strSql AS NVARCHAR(4000) 
 
  EXEC sp_xml_preparedocument @idocImpXml OUTPUT, @ImpXML   ---获取文档句柄
  --初始化项目
  SELECT @strProjGUID = ProjGUID,@strProjCode = ProjCode  FROM OPENXML(@idocImpXml,‘/ImpData‘)
                                              WITH (ProjGUID uniqueidentifier ‘@ProjGUID‘,
                                                    ProjCode CHAR(50) ‘@ProjCode‘)
 
  SELECT
   CostGUID, CostNameCode,CostCode,EstimateFoundation,Unit
   ,Qty,Price,HkqAmount,BqftRate,Amount,Remarks,GetMode
  INTO #tbImpField
  FROM
  OPENXML(@idocImpXml,‘/ImpData/row‘,2)
  WITH
  (
     CostGUID UNIQUEIDENTIFIER ,
     CostNameCode VARCHAR(40),
     CostCode VARCHAR(100),
     EstimateFoundation VARCHAR(100),
     Unit VARCHAR(50) ,
     Qty MONEY ,
     Price MONEY ,
     HkqAmount MONEY ,
     BqftRate MONEY ,
     Amount MONEY ,
     Remarks VARCHAR(4000),
     GetMode VARCHAR(20)
  )       

 ---关闭句柄
  EXEC sp_xml_removedocument @idocImpXml

数据库中解析XML

标签:

原文地址:http://www.cnblogs.com/KingUp/p/5740568.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!