Original: http://blog.csdn.net/kk185800961/article/details/12276449
SQL Server R2
Ssis_foreach Loop Container _foreach File Enumerator (the contents of all TXT files under the import path)
1. Drag a Foreach Loop container to control flow, and then drag a data Flow task into the Foreach Loop container.
2. Edit the Foreach Loop container, select the Foreach file enumerator in the Options collection, and configure the folders and file types to traverse.
3. Add a traverse to the option "variable mapping", which is used to store the full path of the file each time the container traverses.
4. OK, the "Foreach Loop Container" configuration is complete and the data flow is now designed. Add a "Flat File source" and "OLE DB destination" to the data flow interface to connect the data flow.
5. Edit the Flat file source and create a new flat Connection Manager to find any file in the TXT directory (as all TXT file content formats)
6. In the "column" Selection of the format, I tested only two columns. After completion, you can set the name of the output in another "column" in the outer layer.
7. After the OLE DB destination defines the database connection, I import the data into a new table in the database. First click on "New" a table, OK after the database in the new.
8. Two data sources when selected, right-click the Txtsource property and select the button to the right of Expressions.
9. Attribute Select "ConnectString", the expression selection button, find the previously defined file variables, drag the mouse to the following text box, OK!
10. At this point, the design is complete, now run, the result, the program runs 5 times, 1 lines at a time. I tested one record per file, so there were only 5 entries.
Complete!
SSIS "Foreach Loop container _foreach File Enumerator" (The contents of all TXT files under the import path) (GO)