How to Use an SSIS Foreach Loop Container
The Microsoft SSIS "foreach" loop container iterates through each record or column and performs SQL processes on each value in the loop. Use this procedure to edit large amounts of data stored in a table or view structure. The SQL Server SSIS utility includes the foreach loop container to simplify administration tasks that require you to edit data frequently.
Instructions
-
-
1
Open SQL Server Management Studio on your desktop and log in to your database server. Right-click the SSIS package and click "Modify."
-
2
Click the "Control Flow" tab and click "Foreach Loop." In the first general window, type a name and description for the loop container.
-
-
3
Select the type of enumeration list in the "Collection" tab. For instance, if you want to use a list of columns, choose "Columns."
-
4
Click "Add" to add the columns to the list. A list of tables appears. Drag and drop each column you want to use to the "Active" panel.
-
5
Click "Expressions." In the opened panel, type the SQL code you want to execute on each list item. For instance, type "update table set column = ltrim(column)" to trim any spaces from the left side of the column values.
-
6
Click "Save" to save the foreach loop container. Right-click the SSIS package and click "Execute" to run the package on the database with the new foreach loop changes.
-
1