In this post we are going to look at every aspects of For Loop Container Task.

We are covering following points in this article

Why For Loop Container Task is Use ?

How For Loop Container Task is look like ?

Features of For Loop Container Task

How to use For Loop Container Task ?

What is alternative for For Loop Container Task ?

Demonstration of using For Loop Container Task ?

Various Properties for For Loop Container Task ?

Reference link for For Loop Container Task

Now lets understand one by one :

Why For Loop Container Task is Use ?

Name of the task itself explains most of of it !! For Loop container is falls under container and looping tasks

Use containers like the For Each Loop and For Loop to execute a set of tasks multiple times.

For example, you can loop over all the tables in a database, performing a standard set of operations like updating index statistics. In short when we have to iteratively execute set of task we will insert all those task under For Loop Container and set the values accordingly

For loop task is the looping implementation of a task and also This task will evaluate an expression and loops through the process and until the evaluation goes to False.

The For Loop container uses the following elements to define the loop:

An optional initialization expression that assigns values to the loop counters.

An evaluation expression that contains the expression used to test whether the loop should stop or continue.

An optional iteration expression that increments or decrements the loop counter.

How For Loop Container Task is look like ?

This is very first task in tab itself !!

Drag this out in your development plane

Features of For Loop Container Task

The following diagram shows a For Loop container with a Send Mail task. If the initialization expression is @Counter = 0, the evaluation expression is @Counter < 4, and the iteration expression is @Counter = @Counter + 1, the loop repeats four times and sends four e-mail messages.

How to use For Loop Container Task ?

Its very simple to use having actually three properties to set and its ready to use

1. InitExpression: Insert Initialization Expression here ,Initialization ensures that we are starting by setting out increment counter to 1.

2.EvalExpression: Insert Evaluation Expression here , For each iteration the evaluation expression checks to see if we have reached our maximum iteration count as set above when we defined @Counter.

3. AssignExpression: Insert an Assignment Expression here , This is used to increment the counter by one for each iteration of the loop, otherwise the loop would never finish.

What is alternative for For Loop Container Task ?

I think there is no alternative for this Directly ,If you ask still is there then there is we can call one package inside each other ..Think Think !!!

Better not search for this

Demonstration of using For Loop Container Task ?

1. Start in the package Control Flow, with no object selected . 2. Right click the background in the package, and select Variables 3. Add a variable called LoopIteration with the Int32 data type in the package.

4. Add a For Loop Container to the package

5. Edit the For Loop Container by double-clicking it, or right-clicking it and choosing Edit. 6. Set the InitExpression to @[User::LoopIteration]=0 7. Set the EvalExpression to @[User::LoopIteration]<5 where 5 would is the number of loops you want to run. 8.Set the AssignExpression to @[User::LoopIteration]=@[User::LoopIteration]+1 9.Your settings should now look like this:

We can Use For loop Container as Do While Loop too as explained in following post :

This is default properties of for loop task , If in a Loop container,the contents of that loop fail, then the entire container is failed at the same time.

Every now and then we need to create loops that do not fail when the contents fail – for example because failure is permitted or handled within the container.

We can set this too by allowing a loop to continue even if its contents have failed is to set the ForceExecutionResult property to Success, and every iteration of the loop will be treated as successful, regardless of what happens during the loop.