May 29, 2014 at 9:36 am
Hi all,
Just wondering if anybody could help me.
The statement below keeps throwing up the following error incorrect syntax near '@temp'
the code is as follows
declare @number as int
declare @temp as varchar(50)
set @temp= 'C:\' + cast(@number as varchar(50)) + '.xml'
INSERT INTO XMLwithOpenXML(XMLData, LoadedDateTime)
SELECT CONVERT(XML, BulkColumn) AS BulkColumn, GETDATE()
FROM OPENROWSET(BULK @temp, SINGLE_BLOB) AS x;
When hard code the path in it works.
Thanks
May 29, 2014 at 9:48 am
Perhaps a variable in that part of the OPENROWSET clause isn't supported, although I can't find that documented anywhere. You may have to use dynamic SQL instead. Beware of SQL injection if you do.
John
May 29, 2014 at 2:47 pm
To the best of my knowledge, nothing in OPENROWSET can be a variable. It either needs to be hard-coded or be dynamic SQL. As previously suggested, be careful to ensure that your dynamic SQL is bullet proof when it comes to SQL Injection.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply