SSIS [Foreach loop container _ Foreach file enumerator] (content of all txt files in the import path )),

Source: Internet
Author: User
Tags ssis

SSIS [Foreach loop container _ Foreach file enumerator] (content of all txt files in the import path) (convert ),

Original article: http://blog.csdn.net/kk185800961/article/details/12276449

SQLServer 2008 R2

SSIS_Foreach loop container _ Foreach file enumerator (content of all txt files in the import path)


1. Drag a Foreach loop container to control flow, and then drag a Data Flow task to Foreach loop container.



2. Edit the Foreach loop container, select the Foreach file enumerator in the Set option, and configure the folder and file type to be traversed.



3. Add a traversal in the variable ing option. This traversal is used to store the complete path of the file that the container traverses each time.



4. Now, the Foreach loop container configuration is complete. Now, design the data stream ]. Add a flat file source and ole db destination to connect to the data stream.



5. Edit the flat file source and create a flat Connection Manager to find any file in the txt directory (because all the txt files are in the same format)



6. Select the intermediate format in [column]. I only tested two columns. After that, you can set the output name in another "column" on the outer layer.




7. After the [ole db target] defines the database connection, I import the data to the new table of the database. Click [new] to create a table, and then create a table in the database.



8. Right-click the txtSource attribute and select the button on the right of the two data sources.



9. Select ConnectString for the property, select the expression button, find the file variable defined previously, and drag the mouse to the text box below, OK!



10. At this point, the design is complete, and now it runs. As a result, the program runs five times, one line at a time. I tested one record for each file, so there were only five records.




Done!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.