SSIS For Loop Help

  • I have a for loop that has two variables, variableX and variableY passed to it by two execute sql tasks. Within the for loop my EvalExpression is variableX <= variableY. Within the For Loop I have a data flow that takes the bottom N number of records and processes them, then it loops around and processes the next N number of records. After each loop it updates a table with a value that I'm grabbing variableY from so it knows which records to grab next. The problem is, I can't seem to figure out how to update variableY after each loop. So the package runs fine but it errors out at the end because it tries to process even though there are no records left to process. It's seems like it should be pretty simple to solve, but I haven't had much luck. I tried updating the variable after the data flow with another execute sql task, but that doesn't seem to work. Any help would be much appreciated!

  • You should try creating an object variable and using an execute sql task to insert all rows you want to be looped through into the list. Then use a for Each loop to loop through the records. Alternitaly use package configurations to dynamicaly grab your variable from the table. There is lots of help for using Package configurations online and is my preffered way of dynamilcally setting variables from SQL tables.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply