Question

I'm using the below SQL statement in a OLEDB command transformation.

Syntax 1:

INSERT INTO dbo.Table1 (col1,col2) 
SELECT ?, 22 FROM dbo.Table1

But, it fails with an error:

syntax error , permission violation or other nonspecific error.

However, this syntax works fine.

Syntax 2:

INSERT INTO dbo.Table1 (col1,col2) 
values (?,?) 

Is Syntax 1 not supported by SSIS?

Était-ce utile?

La solution

There's a hack to make it work & Martina White (http://dataqueen.unlimitedviz.com/) helped me out with it.

Below is her transcript:
I can duplicate your issue.  There is a funky issue with OLE DB Command.   When I write the query with the Values statement commented out, the Syntax 1 query as you have written it does work.  When I remove the commented out statement it does not work.  It seems to want the word Values() in there, regardless of whether it is commented out.

Try this and see if you get the same behaviour. If so, this should work successfully for you.

INSERT INTO dbo.Table1 (col1,col2) 
--Values()
SELECT ?, 22 FROM dbo.Table1

Autres conseils

No, it is not; in fact, it's not supported by any database that I'm aware of. You cannot parameterize the columns of a SELECT statement.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top