Question: I’m experiencing a frustrating issue when trying to call a proc in an OLE DB source task. I’m using the SQL command from variable data access mode but I can see that it isn’t evaluating my variable correctly.

My variable (with ValidateAsExpression set to True) uses an expression to create a sql command like “EXEC ProcName ‘Param'” where the value of Param comes from a variable who’s value I set using an EXEC SQL task. Below is the expression:

```
“EXEC ProcName ” + “‘” + @[User::vDateThreshold] + “‘”

```

If I use a variable in my source that references a static value it works fine, but the issue seems to be when I use a variable which reference another variable in its expression.

Has anyone else come across this issue?

I’m using this method because I’ve had a similar issue when trying to use a parameter with the sql command data access method.

Thanks in advance

Answer: 
> 
> I’m using this method because I’ve had a similar issue when trying to use a parameter with the sql command data access method.
> 
> 
> 

The right way to do that is by using SQL Command with parameters:

```
EXEC ProcName ?

```

And select `@[User::vDateThreshold]` as parameter.

* [Parameterized OLEDB source query](https://stackoverflow.com/questions/18288183/parameterized-oledb-source-query)

If it is not working then check your procedure code and make sure it generate a specific result set. If the result set is dynamic and columns are not fixed then you have to define it in the query using WITH RESULTSETS keyword.

* <https://www.mssqltips.com/sqlservertip/2356/overview-of-with-result-sets-feature-of-sql-server-2012/>
Thank you for the responses to my question.

I actually found the issue was with the ordering of my tasks in the package. When I looked closer at the values assigned to the relevant variables by using a break point on my exec SQL task I could see the wrong date was being passed to my proc. When I set the value of vDateThreshold at an earlier point the correct date value was assigned.

I think this was a case of looking at something for long enough that I was missing the obvious.