Thursday, June 13, 2013

Batch ETL of Multiple Data Files Using an SSIS Foreach Loop Container 2

5. Add a Foreach Loop Container to BaseBatchETL.dtsx

Drag-and-drop a Foreach Loop Container from the Toolbox into the Control Flow panel.

Drag the Data Flow Task into the Foreach Loop Container.

6. Configure the Foreach Loop Container

Click on the Variables tab and ad the global variable FilePath.

Double-click on the Foreach Loop Container to bring up the Foreach Loop Editor, then click on the Collection node.

Change the contents of the Folder textbox to C:\BatchETL\ and the Files textbox to NewCustomers*.txt, then click on the Variable Mappings node.

Select the Variable User::FilePath and set the Index to zero, then click the OK button to close the Foreach Loop Editor.

7. Configure the SourceConnectionFlatFile connection manager

Click on the SourceConnectionFlatFile connection manager to bring it up in the properties window. Click on the  button next to the Expressions parameter...

...to bring up the property expressions editor. Set the Connection string property to the FilePath global variable we created earlier, then click the OK button to return to the main editing window.
At this point the package will process multiple files. We are now going to add a script task to move each data file to backup as it is extracted.

No comments:

Post a Comment