Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

xml Expand / Collapse
Author
Message
Posted Tuesday, November 13, 2007 3:39 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Yesterday @ 7:33 AM
Points: 49, Visits: 399
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
Post #421818
Posted Sunday, October 28, 2012 11:58 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, January 7, 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
Post #1378112
Posted Thursday, November 15, 2012 7:39 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, November 15, 2012 7:33 PM
Points: 9, Visits: 0




Post #1385420
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse