Monday 23 December 2013

SSIS SQL Task sub query parameter

In an SSIS package I encountered this error when trying to use a Parameter "?" within a SQL statement that uses a sub query .

TITLE: Microsoft Visual Studio
------------------------------

Parameters cannot be extracted from the SQL command. The provider might not help to parse parameter information from the command. In that case, use the "SQL command from variable" access mode, in which the entire SQL command is stored in a variable.

------------------------------
ADDITIONAL INFORMATION:

Syntax error, permission violation, or other nonspecific error (Microsoft SQL Native Client)


This occurred when attempting to pass a parameter ? in side the sub query.

There are two solutions to this. As the error suggests put your complete query in a variable and pass the parameter in that or rewrite your SQL query so the parameter is place outside of the sub query.