Reputation: 709
I am trying to do a loop through a few data flow tasks. With each loop it increases the date variable by 1 (which is stored in a variable). Inside the data flow tasks I have a lookup
task that is supposed to use the variable which is being incremented as part of the sql statement, something like this:
Select
*
From
Table
Where
Date = @[User::Date]
But this doesn't work, I get this error:
Must declare the scalar variable "@".
Any help in trying to get this variable into the sql of the lookup
would be greatly appreciated. I've also tried using parameters within the lookup
but also get an error saying there isn't enough parameters
Upvotes: 4
Views: 16669
Reputation: 350
You could use a logical expression in a derived column component to check the dates and assign a bool value to a new column then use a conditional split to parse records and modify the data flow.
Image: Derived column expression example
Upvotes: 0
Reputation: 2130
Use a derived column before the lookup and the set the value of the new column to the variable. Then in the lookup transform you can just do a straight mapping with the new derived column and the date column in your table and lookup intended columns.
In your case it looks like you would need to use SQL due to the nature of your requirement. Hence after changing your Cache Mode to Partial Cache, go to advanced tab and change your SQL to -
Select *
From Table
Where Date <> ?
Click on parameters button and map your derived column to Parameter0. Hence the Lookup Match output would now essentially give you all the dates that does not match your derived column that is set by the variable @[User::Date].
Upvotes: 5