Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with OpenRowset syntax

Status
Not open for further replies.

batteam

Programmer
Sep 12, 2003
374
0
0
US
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top