I need to load an XML file into a SQL table, then select data from it. Big problem is that my position does not have permission to use the Bulk option of the OpenRowset commnad. I won't be needing most of the XML file so I do not believe I need the Bulk option. I have the following code but get a syntax error.
CREATE TABLE dbo.XmlImportTest
(
xmlFileName VARCHAR(300),
xml_data xml
)
GO
DECLARE @xmlFileName VARCHAR(300)
SELECT @xmlFileName = 'H:\TestXmlDoc.xml'
EXEC('
INSERT INTO dbo.XmlImportTest(xmlFileName, xml_data)
SELECT '' + @xmlFileName + '', xmlData
FROM
(
SELECT *
FROM OPENROWSET ('' + @xmlFileName + '') AS XMLDATA
) AS FileImport (XMLDATA)
')
GO
SELECT * FROM XmlImportTest
DROP TABLE dbo.XmlImportTest
The error I get is in the 'From OpenRowSet...' command line, at the ")" part of the command. Can the OpenRowSet be used without the Bulk option? If so, what would be the correct syntax? Thanks for any help you can provide.
CREATE TABLE dbo.XmlImportTest
(
xmlFileName VARCHAR(300),
xml_data xml
)
GO
DECLARE @xmlFileName VARCHAR(300)
SELECT @xmlFileName = 'H:\TestXmlDoc.xml'
EXEC('
INSERT INTO dbo.XmlImportTest(xmlFileName, xml_data)
SELECT '' + @xmlFileName + '', xmlData
FROM
(
SELECT *
FROM OPENROWSET ('' + @xmlFileName + '') AS XMLDATA
) AS FileImport (XMLDATA)
')
GO
SELECT * FROM XmlImportTest
DROP TABLE dbo.XmlImportTest
The error I get is in the 'From OpenRowSet...' command line, at the ")" part of the command. Can the OpenRowSet be used without the Bulk option? If so, what would be the correct syntax? Thanks for any help you can provide.