Reputation: 16239
I have one temp folder C:\Mydata
inside that i have .csv
files with name
demo1.csv
demo2.csv
...etc
Now I want to insert data from all those files into database table
for this I have taken Foreach Loop Container
in the property Directory
I mention
C:\Mydata
inside Foreach Loop Container
taken a Data Flow Task
in that Flat File Source
is there in the connection manager property in file name
what should I mention, so that it will traverse through all folder and all files whose extension is .csv
I did like C:\DEMO\*.csv
which is giving me error :
no file found path is wrong
Upvotes: 1
Views: 2322
Reputation: 746
From what i interpreted, your issue was assigning the resulting file from the foreach to the connector.
To do that you need to assign the filename from the Foreach to a variable.
The first step to be taken is to create the variable. To do that you need to activate the "Variables" window:
Then you need to create a new variable of type string and rename it.
For more information on SSIS variables and how to create them, see http://msdn.microsoft.com/en-us/library/ms140216.aspx
Now you need to assign the new variable (in this case i named it "filename") to the foreach loop:
NOTE THAT WHILE THE OPTION "Name Only" IS SELECTED IN THE FIRST WINDOW, IN YOUR CASE YOU PROBABLY WANT "Fully Qualified"!!
The screenshot was taken from a working project i have and i am using only the name (Name Only) as opposed to the full path (Fully Qualified)
After doing that you need to assign that variable to your flat file connector using expressions:
Upvotes: 3
Reputation: 16260
Which version of MSSQL and SSIS are you using? And why are you using C:\Mydata in one place and C:\DEMO in another?
The basic technique of looping over files is described here.
There is lot of information about these steps in the documentation and on the web. If you need more help, please be as specific as possible about what you've tried, what isn't working, what versions you're working with etc.
Upvotes: 2