1

I have created 2 variables in SSIS, namely ProductValue and SQLQuery. The SQLQuery contain the sql statement as below:

"SELECT * FROM Products Where ProductID > " + @[user::ProductValue]

When I pass the SQLQuery variable to Ole db source via data access mode = sql command from variable, system return the error messages as below:

Error at Data Flow Task [OLE DB Source [1]]: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80040E14.
An OLE DB record is available.  Source: "Microsoft SQL Server Native Client 10.0"  Hresult: 0x80040E14  Description: "Statement(s) could not be prepared.".
An OLE DB record is available.  Source: "Microsoft SQL Server Native Client 10.0"  Hresult: 0x80040E14  Description: "Incorrect syntax near '+'.".

3 Answers 3

4

You need to have your SQL Query variable set to EvaluateAsExpression.

If you check the value of the SQL Query Variable in the Variables Grid it should say something like:

SELECT * FROM Products Where ProductID > 1

If it doesn't then you have not defined your variable properly. The Value of your SQL Query variable should not contain any quotes or +, only the expression should in this case.

Sign up to request clarification or add additional context in comments.

3 Comments

How to "You need to have your SQL Query variable set to EvaluateAsExpression" ?
@KumarVaibhav it's in the variable properties
can't the variable be initialized by value at runtime. In my case i am generating the SQL query at run time upon checking conditions and wanted to store them in variable and later that variable to use it in Data flow task... is it possible?
0

In case anyone runs into this thread, you can change the setting when selecting "Show advanced editor" (=right click on the Oledb source) and select "Component Properties" tab and switch "AccessMode" to "SQL Command From Variable".

Comments

0

Put the command like this: "SELECT * FROM Products Where ProductID > " + (DT_STR, 10, 1252) @[user::ProductValue] + ""

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.