4

I know this has been asked earlier.
Most of the answers were not relevant.
Google, shows that the solution is to configure the expression in the "data flow task" and set the query.

However in the ADO .NET source, when I try to preview the output I keep getting "Must declare the variable '@'"
It does not show the full variable in this error - "@[User::GLOBAL_PARAMETER]"

I think that's because "[USER::" isn't the correct syntax inside a SQL; but then how does one set it ?!

2
  • Also - When I configured the SQL command expression in the Data flow task, I put it in quotes, so its taken as a string literal. I guess that's how everyone has done it. Commented Dec 20, 2011 at 21:31
  • I don't understand your question: where exactly are you trying to use the variable and for what? A "data flow task" is a container, and you usually use variables in other tasks or in transformations within the data flow task. You need to clarify exactly where you are setting the variable and what it represents, e.g. a connection string, a SQL string, a file name etc. Commented Dec 21, 2011 at 8:59

1 Answer 1

3

From your description it seems like you are having an error due to using the variable name inside the query string as opposed to the processed variable value. In other words:

"SELECT * FROM @[User::TABLE]" in the expression builder would be WRONG

"SELECT * FROM " + @[User::TABLE] would be CORRECT

It would help if you shared the expression you are using as a query

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

2 Comments

Small correction, don't understand it but had to add DT_WSTR, 30) in front of the @[User::TABLE] for it to work correctly. But thanks you've provided with 99% of the solution !
@PlanetUnknown the (DT_WSTR, 30) is a conversion of the data type to string. You must use for any variable that is not "string". Glad to be of help

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.