Importing files in multiple folders at the same time using ssis

  • 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

  • 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.

  • 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.

  • Use a for each loop with the transverse subfolders option set and then you can change the connectionstring of the csv connection manager dynamically.

  • @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 😉

  • 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

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply