Saturday, December 11, 2010

SSIS: Foreach File Enumerator in Foreach Loop Container with dynamic folder path using variables

Setting the folder path in foreach loop container dynamically using a variable.

This can be done by setting the Directory property of the Foreach File Enumerator.

1. Create two variables named @FolderPath and @FileName.

2. Drag a Foreach Loop Container task to the Control Flow panel, double click it to pop up the property window.

3. Switch to the Collection tab, choose the Enumerator as "Foreach File Enumerator", expand Expressions and add two properties "Directory" for folder path and "FileSpec" for filtering specific types of files. Specify "@[User::FolderPath]" to Directory and "*.txt" to FileSpec.

4. Switch to the Variable Mappings and specify User::FileName mapping to the index 0.

No comments:

Post a Comment