Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Differenciate FOR LOOP and FOREACH LOOP IN SSIS Expand / Collapse
Author
Message
Posted Friday, May 28, 2010 6:52 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, July 22, 2010 6:57 AM
Points: 6, Visits: 27
Hi

Could anyone kindly explain the difference between FOR LOOP and FOREACH LOOP with example(if possible) in SSIS.

Thanking you,

Regards
Ram
Post #929630
Posted Friday, May 28, 2010 7:10 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Thursday, September 19, 2013 7:41 AM
Points: 1,626, Visits: 477
A for loop will execute the tasks a specified number of times, in other words 10 times, or 25 times, and the number of times is specified in the definition of the container. You can use a variable to specify what that count is.

A for each loop will execute once for each item in the collection of items that it is looking at. A good example would be if users are putting an Excel file into a directory for import into the DB. You cannot tell ahead of time how many will be in the directory, because a user might be late, or there might be more than one file from a given user. When you define the ForEach container, yoou would tell it to execute for each *.xls in the directory, and it will then loop through, importing each one individually, regardless of how many files are actually there.

Hope that helps.
Rich
Post #929644
Posted Friday, May 28, 2010 12:04 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, July 22, 2010 6:57 AM
Points: 6, Visits: 27
Hi Rich,

The example and explanation you have posted was precise and clear.

I appreciate for your time.

Thanking you,
Ram
Post #929864
Posted Tuesday, July 31, 2012 3:43 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, September 07, 2012 6:45 AM
Points: 1, Visits: 24
Thanks Rich...That's useful and straight forward.
Oscar
Post #1337757
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse