June 11, 2008 at 11:36 am
Can somebody help me importing XML file into sql 2005 table.
Thanks a lot.
June 11, 2008 at 11:59 am
Here is a sample that loads an xml file to a table with an xml column.
INSERT INTO InventoryFeeds (InventoryXML)
SELECT InventoryXML
FROM ( SELECT * FROM OPENROWSET
(BULK 'C:\Test\Inventory.xml', SINGLE_CLOB) AS xmlData) AS feed (InventoryXML)
June 11, 2008 at 12:25 pm
Thanks a lot but how to parse into columns.
June 11, 2008 at 12:41 pm
Here is a sample of inserting from the table with the xml datatype to a parsed table.
INSERT INTO SERVERS(SerialNumber,Manufacturer,Model,SystemType)
Select
InventoryXML.value('(/Root/Server/SerialNumber)[1]','varchar(50)') SerialNumber,
InventoryXML.value('(/Root/Server/Manufacturer)[1]','varchar(50)') Manufacturer,
InventoryXML.value('(/Root/Server/Model)[1]','varchar(50)') Model,
InventoryXML.value('(/Root/Server/SystemType)[1]','varchar(50)') SystemType
FROM InventoryFeeds where InventoryFeedID =@InventoryFeedID
June 11, 2008 at 1:04 pm
I new to xml. Here is my xml file. How can I use your insert function to parse into columns.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
June 11, 2008 at 1:25 pm
Here is the XML file. How can I use insert statement to parse into column
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
June 11, 2008 at 8:42 pm
Just attach it as a text file.
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
June 12, 2008 at 11:24 am
I am able to extract data from XML files using SSIS package through XML Source component. It looks ok but there is little problem about datatype. Default datatype for one of the xml column is unsigned integer (DT_UI8) but in sql server there is no unsigned integer type, so I have to change the datatype from DT_UI8 to DT_I4 (integer)
June 12, 2008 at 4:25 pm
balbirsinghsodhi (6/12/2008)
I am able to extract data from XML files using SSIS package through XML Source component. It looks ok but there is little problem about datatype. Default datatype for one of the xml column is unsigned integer (DT_UI8) but in sql server there is no unsigned integer type, so I have to change the datatype from DT_UI8 to DT_I4 (integer)
No, I mean attach your example as a text file to this discussion. We cannot see your previous two attempts, because the forum software strips out anything that might be html or xml tags.
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply