Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Importing files in multiple folders at the same time using ssis Expand / Collapse
Author
Message
Posted Wednesday, December 12, 2012 5:36 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Saturday, September 6, 2014 1:45 PM
Points: 112, Visits: 1,481
I have 10 folders each receiving a .csv file on a daily basis. I would like to create a package to import these files into a database on a daily basis.


Data/Ab1/mon.csv

Data/Ab2/mon.csv

Data/Ab2/mon.csv


I know i could probably create single packages for each file import in each folder but i would like to know if i can create a single package to to run all the imports at the same time.

Can anyone explain the steps to do this?

I understand i can use a Foreach Loop Container..but I am a little unsure how.

Regards

Post #1395607
Posted Wednesday, December 12, 2012 5:57 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Yesterday @ 12:16 AM
Points: 461, Visits: 693
The short answer is yes

Are the files going into the same table, if so is there any need to identify which file or folder they came from. If not then you can just use Bulk Insert Task.

If the data is going to different tables or needs the file identifier on it then you will need to use a Data flow Task and the data transormation options to insert, convert and lookup column values

Are the folder names dynamic, If not then the BFI (Brute Force and Ignorance) method would be best: Create 10 FlatFileConnections

If they are dynamic then you can change the connection string of the FlatFileConnection string using an expression, but the formats of the source files must be the same.
Post #1395618
Posted Wednesday, December 12, 2012 7:19 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Saturday, September 6, 2014 1:45 PM
Points: 112, Visits: 1,481
Yes the files are going into the same table. There is no need to identify which folder they came from. Ive looked at the Bulk Insert Task, but am a little unsure how to Bulk insert multiple files in these multiple folders.




Post #1395660
Posted Wednesday, December 12, 2012 7:52 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Monday, December 8, 2014 1:45 AM
Points: 5,221, Visits: 5,120
Use a for each loop with the transverse subfolders option set and then you can change the connectionstring of the csv connection manager dynamically.



Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger

Post #1395680
Posted Thursday, December 13, 2012 8:26 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Yesterday @ 12:16 AM
Points: 461, Visits: 693
@Anthony.

Do you mean change the FlatFileConnection on each loop (i.e. 10 FFCs and choose each one dynamically) or do you mean one FFC and change it's source in each loop.

To be honest, if it is really only 10 folders and the folders are static, I would just set up 10 bulk insert tasks with 10 FFCs and be done with it

Post #1396223
Posted Thursday, December 13, 2012 8:30 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Monday, December 8, 2014 1:45 AM
Points: 5,221, Visits: 5,120
1 ForEach loop with 1 flat file connection, grabs the files from a sub folder, changes the connection string of the ffc at loop time.

The issue now comes down with are the files and folder names static or can they change and what happens to the file after it has been imported, which will determine which way to write the package





Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger

Post #1396228
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse