Import XML into SQL Server 2005 data not imported

SIlviuB

New Member
I have a table titled Code, with two fields, ID and Code. I have an XML file: \[code\] <DataSet> <scan> <ID>4</ID> <Code>420</Code> </scan> <scan> <ID>5</ID> <Code>420</Code> </scan> <scan> <ID>6</ID> <Code>420</Code> </scan> <scan> <ID>4</ID> <Code>420</Code> </scan> <scan> <ID>5</ID> <Code>420</Code> </scan> </DataSet>\[/code\]and am using this \[code\] INSERT INTO code (id,code) SELECT X.scan.query('id').value('.','INT'), X.scan.query('code').value('.','VARCHAR(30)') FROM ( SELECT CAST(x AS XML) FROM OPENROWSET( BULK 'C:\dataimport.xml', SINGLE_BLOB) AS T(x) ) AS T(x) CROSS APPLY x.nodes('dataset/scan') AS X(scan);\[/code\]The query runs without error, but no data is inserted into the Code table. I can't see what I'm missing. Thanks for your help.
 
Back
Top