



The varFilePath variable will be updated on each iteration of the file in the Foreach Loop container. Note: The flat file connection needs to be dynamic, so one connection can load several files from the source folder. Configure the flat file ConnectionString Property as an expression to make the flat file connection dynamic.Create a flat file connection (NightlyDataFile) for any available file in the SourceFolder (in this example, use the file name C:\SSIS\NightlyData\Nightly_01.txt).Create an oledb connection ((local).tempdb) to use tempdb database.The sample package requires two connections: OLE DB and flat file. Is + + "\\" + + "\\" + The “Is Expression” column refers to the EvaluateAsExpression property of the SSIS variable. SSIS Foreach Loop Container Configuration InstructionsĬomplete the following step-by-step instructions for this sample to configure the SSIS Foreach Loop container: Define Variable Mappings The sample package uses five variables with the following settings: Variable Name Open FAQTest.sln and analyze or run the Sample Package to test it.Copy the provided sample files to C:\SSIS\NightlyData.Create a Folder C:\SSIS\NightlyData\Archived.Download and Extract the For_Each_Loop_File_Test.zip file.After each file is processed, it's moved to the Archive folder.Ĭomplete the following six steps to set up the test Sample SSIS Package: The following sample SSIS Package shows you how to process each file ( Nightly_*.txt) in C:\SSIS\NightlyData. Common types of Foreach Loop container enumerators include: A Foreach Loop container executes as many times as needed over a specified enumerator type. A For Loop container uses expressions to define a fixed number of times to execute. You can use an SSIS Foreach Loop container to define a control flow task to loop through different types of enumerators, such as files, in a specified folder.Ī Foreach Loop container is like a For Loop container but differs when it comes to the number of times the loop executes. This same process in SSIS is much easier. Processing files in a specific folder in DTS takes a good amount of work. In this post, I’ll address another common question related to using SSIS for looping through and loading files to move them to an archive folder by configuring a Foreach Loop container.

In a previous post, I answered a question regarding SSIS packages using 32-bit drivers and 64-bit machines.
