Thursday, July 8, 2010

Importing XML from a file into an XML column

The following will import the XML from a file into a column in a table with the XML Data Type in SQL Server.

INSERT INTO T(XmlCol)
    SELECT * FROM OPENROWSET(
     BULK 'c:\SampleFolder\SampleData3.txt', SINGLE_BLOB) AS x
You must include the as X to name the column or the import will fail. 
THis example and more can be taken from here http://msdn.microsoft.com/en-us/library/ms191184.aspx

No comments:

Post a Comment