Shredding XML from DB using SSIS

半腔热情 提交于 2019-12-08 05:38:17

问题


I am looking for a way to pull XML from a SQL database and shred the XML via SSIS in bulk. I currently have a package that can pull XML from the database and pass the XML to a stored procedure, via variable, for shredding but this only works 1 record at a time. When processing 100,000 records, this can become quite time consuming.

I would like to shred multiple XML values at once using SSIS. Is this possible with SSIS? Perhaps something in a Data Flow Task where all the XML values are selected from a source then passed to a parser of some sort?


回答1:


So after a lot of searching and thinking about the problem, I redesigned the stored procedures that did the shredding. Instead of shredding a variable being passed into the stored procedure, I just shredded from the XML column itself. This allowed me to shred many XML values at once instead of looping and passing them to a stored procedure one at a time. This gave me the performance boost I was looking for. So instead of something like this...

SET @xmlData = CAST(@xmlMessageData AS XML)

SELECT
   , row.value('xmlNode1[1]', 'BIT' )                   AS Column1  
   , row.value('xmlNode2[1]', 'NVARCHAR(255)')          AS Column2
   , row.value('xmlNode3[1]', 'BIT' )                   AS Column3
   , row.value('xmlNode4[1]/Name[1]', 'NVARCHAR(255)' ) AS Column4
FROM @xmlData.nodes('xmlRootNode') AS T1(row)

I now do this...

SELECT
   , row.value('xmlNode1[1]', 'BIT' )                   AS Column1  
   , row.value('xmlNode2[1]', 'NVARCHAR(255)')          AS Column2
   , row.value('xmlNode3[1]', 'BIT' )                   AS Column3
   , row.value('xmlNode4[1]/Name[1]', 'NVARCHAR(255)' ) AS Column4
FROM [ESBMessagesData] D
CROSS APPLY
    [DataItem].nodes('xmlRootNode') AS T1(row)


来源:https://stackoverflow.com/questions/6309410/shredding-xml-from-db-using-ssis

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!