|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Yesterday @ 12:05 PM
Points: 43,
Visits: 357
|
|
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
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, January 07, 2013 5:45 AM
Points: 1,
Visits: 4
|
|
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
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Thursday, November 15, 2012 7:33 PM
Points: 9,
Visits: 0
|
|
|
|
|