0

i am very new to ssis !

i wanted to know the below.

How to load multiple files into sql-server using ssis tasks?

I am currently working on datawarehouse. i have a bunch of files each in separate folders

the folders are

Myfolder
  ->subfolder_21-03-2009.txt
  ->Mysubfolder_21-03-2009.txt
Myfolder1
  ->subfolder_22-03-2009.txt
  ->Mysubfolder_22-03-2009.txt
Myfolder2
  ->subfolder_23-03-2009.txt
  ->Mysubfolder_23-03-2009.txt

I am able to load Subfolder.*.txt into sql-server DB(table 1) using foreachloop In ssis..

now can somebody tell me how'd i load mysubfolder.*.txt into Sql-server(table 2) DB

i want to load multiple files into sql-server in a single process.

please somebody guide me !

  • can you show us the package/code ? – Erran Morad Mar 28 '14 at 17:57
  • 1
    Package is jus a for each loop with. Dft to load flat file into db with a String variable to iterate, but need to know how could I make a package that could I load 2 or more different files into 2 or more tables respecyively –  Mar 30 '14 at 18:20
  • i have i similar question in mind so i started a biunty on this :) – vhadalgi Mar 31 '14 at 13:51
  • 1
    Duplicate of [Import text files](http://stackoverflow.com/questions/19957451/how-to-import-text-files-with-the-same-name-and-schema-but-different-directories/19957728#19957728) but cannot be closed yet due to the bounty – billinkc Mar 31 '14 at 14:58
  • @billinkc : i dont want to use the BIDS helper... i wnat it in SSIS only thnaks ! –  Apr 02 '14 at 08:32
  • thanks for the guy who put bounty :) –  Apr 02 '14 at 08:32

4 Answers4

4

I am currently working on datawarehouse. i have a bunch of files each in separate folders

seeing this you need to refer this answer also you may check this

and this

this is quite helpful you can take a look here

To answer above you got a sequence container that executes task one after other :

Snapshot 1

Snap shot1

Snapshot 2

You might want to give Mysubfolder.*.txt

Snap shot2

Snapshot 3enter image description here

In the Data flow task you might be doing this

Community
  • 1
  • 1
vhadalgi
  • 7,027
  • 6
  • 38
  • 67
1

You allready have a "ForEachLoopContainer" looping in each folder to load "subfolder_*.txt" in table 1.

Why don't you create a second "ForEachLoopContainer" looping in each folder to load "Mysubfolder_*.txt" in table 2?

Then put those 2 "ForEachLoopContainer" in a sequence container and it's done.

Tom_Doe
  • 146
  • 3
0

If it is a directory of files. Use a ForEach Loop container to enumerate all your files in the directory; because you have subfolders you must click the "traverse subfolders" option. Next you need to put a Data Flow Task in your ForEach Loop Container. Within the Data Flow Task you need to add a Flat File Source. Then you need to add a Derived Column transformation after your Flat File Source. Within your Derived Column you need to add the variable that you used to loop through the directory into the "Derived Column Name"; in the "Derived Column" put "Add as new column", and in the "Expression" you would use a FindString expression or a combination of LEFT/RIGHT expressions to grab the date from the file name. Then in your OLE DB Destination object you need to map your derived column to the relative column in your SQL-Server DB.

FINDSTRING: http://technet.microsoft.com/en-us/library/ms141748.aspx

LEFT/RIGHT: http://technet.microsoft.com/en-us/library/hh231081.aspx

J.S. Orris
  • 4,653
  • 12
  • 49
  • 89
  • 1
    Hmm..this is not what I need man I upvoted your other answer on my question! But this doesn't help me, can you please look above question again ... Thanks ! –  Mar 30 '14 at 18:17
  • Did you check the "traverse subfolders" option in your ForEach Loop container? – J.S. Orris Apr 03 '14 at 18:42
0

I wanted to check to load 3 files with different format into 3 separate tables. Let’s say I have 3 files A, B, C with date as suffix and that changes every day. This is what I did.
Image 1

Create a ForEach Loop Container and set the Collection tab as below.
Image 2

Let’s make the filename date part dynamic using expression for each file connection managers.
Image 3

The final package would look like below.
Image 4

And voila!! The tables are loaded from respective files.
Image 5

Obviously this can be refined by using Foreach File Enumerator getting the fully qualified name of the file in a variable and then writing an Expression to parse it to channelize to different DFTs. Hope this helps.

aschipfl
  • 33,626
  • 12
  • 54
  • 99
Subhraz
  • 11