November 13, 2007 at 3:39 pm
hi
well am on fire rite know ,,,,,,:D
anyways i am new to sql not as expert as you guys but the thing am stuck here is i need to import a simple .xml file into sql server 2005 in a table where there is already a coloumn of (xml)data type in my table so can you please please give me a correct syntax or a method to do this no links plzz as i wont understand in this situation
pleaes help
thanks
October 28, 2012 at 11:58 pm
Hi,
i think the below script will help you. (this is not my script)
CREATE TABLE XmlImportTest
(
xmlFileName VARCHAR(300),
xml_data xml
)
GO
DECLARE @xmlFileName VARCHAR(300)
SELECT @xmlFileName = 'c:\TestXml.xml'
-- dynamic sql is just so we can use @xmlFileName variable in OPENROWSET
EXEC('
INSERT INTO XmlImportTest(xmlFileName, xml_data)
SELECT ''' + @xmlFileName + ''', xmlData
FROM
(
SELECT *
FROM OPENROWSET (BULK ''' + @xmlFileName + ''' , SINGLE_BLOB) AS XMLDATA
) AS FileImport (XMLDATA)
')
GO
SELECT * FROM XmlImportTest
DROP TABLE XmlImportTest
November 15, 2012 at 7:39 pm
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply