May 28, 2010 at 6:52 am
Hi
Could anyone kindly explain the difference between FOR LOOP and FOREACH LOOP with example(if possible) in SSIS.
Thanking you,
Regards
Ram
May 28, 2010 at 7:10 am
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
May 28, 2010 at 12:04 pm
Hi Rich,
The example and explanation you have posted was precise and clear.
I appreciate for your time.
Thanking you,
Ram
July 31, 2012 at 3:43 am
Thanks Rich...That's useful and straight forward.
Oscar
June 26, 2015 at 9:12 am
Very clear explanation.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply