-1

How can I loop through multiple files in a data flow task .

Right now it raeds just one file , what to do if I need to read multiple files in a data flow task

Ritu
  • 1
  • 1
  • 3

1 Answers1

0

There are a lot of things you could do (like moving/deleting the files after reading), but I will keep it just at reading the files.

  1. Create a for each loop in your control flow. (this has to be done in the control flow.)
  2. double click on the for each loop, and go to the collection tab.
  3. Select for each file enumerator (in the drop-down)
  4. Under enumerator configuration, select the right folder and write *.csv under Files. Under Retrieve file name, select fully qualified
  5. Go to the variable mapping tab. Insert the variable CurrentFile with an Index of 0 (should be default)
  6. Close the for each editor window. Add your dataflow in the for each loop container.
  7. Open the dataflow and parametrize your connection manager. Use the variable CurrentFile.
  8. You're ready to go

Some good material (with extras):

https://www.mssqltips.com/sqlservertip/2874/loop-through-flat-files-in-sql-server-integration-services/

http://help.pragmaticworks.com/dtsxchange/scr/FAQ%20-%20How%20to%20loop%20through%20files%20in%20a%20specified%20folder,%20load%20one%20by%20one%20and%20move%20to%20archive%20folder%20using%20SSIS.htm

http://www.sqlis.com/sqlis/post/Looping-over-files-with-the-Foreach-Loop.aspx

http://www.codeproject.com/Tips/803195/Foreach-File-Enumerator-in-SSIS

DenStudent
  • 906
  • 1
  • 13
  • 37