This works on the tradition counter logic, where it has 3 steps.
Let us see in detail, Stepwise...
. Drag and Drop a For Loop Container from the toolbox to the Control Flow Tab
. Select the Container, add a variable from the Variable box. Variable box can be obtained from the Menu SSIS->Variables. say variable name is "count" of data type int.
(When we select the container and create a variable the scope of the variable is set only for Container level, means the variable will not be available for other components outside the container.)
. Right Click on the container and select Edit from the Context Menu displayed.
. In the InitExpression, Enter @[User::count]=0. this assigns the value 0 to the user created variable count.
. In the Eval Expression, Enter @[User::Variable] <10. this sets the loop condition.
. In the Assign Expression, Enter @[User::Variable] = @[User::Variable]+1. this increments the value of the variable by 1 for every loop.
. Select Ok and close the Dialog.
. From the tool box, place a script task in the container.
. Right Click the script task and select edit from the context menu.
. Goto script tab in the left panel.
. Click Design Script button located in the right bottom of the dialog. this opens a vb code page with new studio environment with some code writen already.
. Place the code MsgBox("hai"), in the main subroutine, before the assignment of task result.
. save a close the environment.
. Click ok and close the script edit dialog.
. Right Click the container, select execute container from the context menu.
. this runs the For Loop Container, and the tasks inside it. it displays the Hai message box 10 times and stops the execution.
This example explains the feature of the For Loop Container in a simple, how ever we can use this as per our need in the package.