Monday, June 23, 2008

Import XML Data from File

--Create the table
CREATE TABLE [dbo].[XMLFeeds]( [XMLFeedID] [bigint] IDENTITY(1,1) NOT NULL, [TestXML] [xml] NOT NULL)

--Load the file
INSERT INTO XMLFeeds (TestXML)
SELECT TestXML
FROM ( SELECT * FROM OPENROWSET
(BULK 'C:\Test\Test.xml', SINGLE_CLOB) AS xmlData ) AS feed (TestXML)


--Now you can parse the file using xquery

0 comments: