Share via


Lesson 2: Adding Looping

In Lesson 1: Creating the Project and Basic Package, you created a package that extracted data from a single flat file source, transformed the data using Lookup transformations, and finally loaded the data into the FactCurrencyRate fact table of the AdventureWorksDW sample database.

However, it is rare for an extract, transform, and load (ETL) process to use a single flat file. A typical ETL process would extract data from multiple flat file sources. Extracting data from multiple sources requires an iterative control flow. One of the most anticipated features of Microsoft SQL Server 2005 Integration Services (SSIS) is the ability to easily add iteration or looping to packages.

Integration Services provides two types of containers for looping through packages: the Foreach Loop container and the For Loop container. The Foreach Loop container uses an enumerator to perform the looping, whereas the For Loop typically uses a variable expression. This lesson uses the Foreach Loop container.

The Foreach Loop container enables a package to repeat the control flow for each member of a specified enumerator. With the Foreach Loop container, you can enumerate:

  • ADO recordset rows and schema information
  • File and directory structures
  • System, package and user variables
  • SQL Server Management Objects (SMO)

In this lesson, you will modify the simple ETL package created in Lesson 1 to take advantage of the Foreach Loop container. You will also set user-defined package variables to enable the tutorial package to iterate through all the flat files in the folder. If you have not completed the previous lesson, you can also copy the completed Lesson 1 package that is included with the tutorial.

In this lesson, you will not modify the data flow, only the control flow.

Important

This tutorial requires the AdventureWorksDW sample database. For more information about how to install and deploy AdventureWorksDW, see Running Setup to Install AdventureWorks Sample Databases and Samples.

Lesson Tasks

This lesson contains the following tasks:

Start the Lesson

Copying the Lesson 1 Package

See Also

Other Resources

For Loop Container

Help and Information

Getting SQL Server 2005 Assistance