Differenciate FOR LOOP and FOREACH LOOP IN SSIS

  • Hi

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

    Thanking you,

    Regards

    Ram

  • 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

  • Hi Rich,

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

    I appreciate for your time.

    Thanking you,

    Ram

  • Thanks Rich...That's useful and straight forward.

    Oscar

  • 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