How to: Configure a Foreach Loop Container
This procedure describes how to configure a Foreach Loop container, including property expressions at the enumerator and container levels.
To configure the Foreach Loop container
In Business Intelligence Development Studio, open the Integration Services project that contains the package you want.
Click the Control Flow tab and double-click the Foreach Loop.
In the Foreach Loop Editor dialog box, click General and, optionally, modify the name and description of the Foreach Loop.
Click Collection and select an enumerator type from the Enumerator list.
Specify an enumerator and set enumerator options as follows:
To use the Foreach File enumerator, provide the folder that contains the files to enumerate, specify a filter for the file name and type, and specify whether the fully qualified file name should be returned. Also, indicate whether to recurse through subfolders for more files.
To use the Foreach Item enumerator, click Columns, and, in the For Each Item Columns dialog box, click Add to add columns. Select a data type in the Data Type list for each column, and click OK.
Type values in the columns or select values from lists.Note
To add a new row, click anywhere outside the cell in which you typed.
Note
If a value is not compatible with the column data type, the text appears in red.
To use the Foreach ADO enumerator, select an existing variable or click New variable in the ADO object source variable list to specify the variable that contains the name of the ADO object to enumerate, and select an enumeration mode option.
If creating a new variable, set the variable properties in the Add Variable dialog box.To use the Foreach ADO.NET Schema Rowset enumerator, select an existing ADO.NET connection or click New connection in the Connection list, and then select a schema.
Optionally, click Restrictions and select schema restrictions, select the variable that contains the restriction value or type the restriction value, and click OK.To use the Foreach From Variable enumerator, select a variable in the Variable list.
To use the Foreach NodeList enumerator, click DocumentSourceType and select the source type from the list, and then click DocumentSource. Depending on the value selected for DocumentSourceType, select a variable or a file connection from the list, create a new variable or file connection, or type the XML source in the Document Source Editor.
Next, click EnumerationType and select an enumeration type from the list. If EnumerationType is Navigator, Node, or NodeText, click OuterXPathStringSourceType and select the source type, and then click OuterXPathString. Depending on the value set for OuterXPathStringSourceType, select a variable or a file connection from the list, create a new variable or file connection, or type the string for the outer XML Path Language (XPath) expression.
If EnumerationType is ElementCollection, set OuterXPathStringSourceType and OuterXPathString as described above. Then, click InnerElementType and select an enumeration type for the inner elements, and then click InnerXPathStringSourceType. Depending on the value set for InnerXPathStringSourceType, select a variable or a file connection, create a new variable or file connection, or type the string for the inner XPath expression.To use the Foreach SMO enumerator, select an existing ADO.NET connection or click New connection in the Connection list, and then either type the string to use or click Browse. If you click Browse, in the Select SMO Enumeration dialog box, select the object type to enumerate and the enumeration type, and click OK.
Optionally, click the browse button (…) in the Expressions text box on the Collection page to create expressions that update property values. For more information, see How to: Create a Property Expression.
Note
The properties listed in the Property list varies by enumerator.
Optionally, click Variable Mappings to map object properties to the collection value, and then do the following:
In the Variables list, select a variable or click <New Variable> to create a new variable.
If you add a new variable, set the variable properties in the Add Variable dialog box and click OK.
If you use the For Each Item enumerator, you can update the index value in the Index list.
Note
The index value indicates which column in the item to map to the variable. Only the For Each Item enumerator can use an index value other than 0.
Optionally, click Expressions and, on the Expressions page, create property expressions for the properties of the Foreach Loop container. For more information, see How to: Create a Property Expression.
Click OK.
See Also
Concepts
Foreach Loop Container
Control Flow How-to Topics (SSIS)