October 6, 2017 at 2:48 am
I have 4 file directories, each with files to be processed into one Staging table. the files have same number of columns and data types, however the files has different name.
I was thinking of a Loop or For Each Loop but I don't know how do I set it up to go to 4 different directories, get files there and load them into a table.
Please help.
October 6, 2017 at 3:03 am
A For Each Loop would normally be used if you have multiple files in one directory or set of sub directories. This means that the Loop can iteratively go through each file in the directory. I'm doubt a For Each Loop would therefore work here.
When you say each file has a different name, do you mean each time you load the file the name will be different, or that all 4 files have different names but they are known? Personally, I think you'll need 4 File Connections, 1 for each file. As the files all have the same format, you'll be able to then use a UNION transformation, to combine all the rows, and then insert them into your Staging table.
Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
Larnu.uk
October 6, 2017 at 6:23 am
hoseam - Friday, October 6, 2017 2:48 AMI have 4 file directories, each with files to be processed into one Staging table. the files have same number of columns and data types, however the files has different name.I was thinking of a Loop or For Each Loop but I don't know how do I set it up to go to 4 different directories, get files there and load them into a table.
Please help.
If the files are not too large in size, you could try this simple solution:
1) Copy the files to a central folder
2) Process them using a standard Foreach loop
3) Delete/move the files
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
October 7, 2017 at 10:34 am
create one foreach loop for the folders based on a record set created by a script
then within the foreach do another foreach for each file within that folder.
see http://microsoft-ssis.blogspot.ie/2011/01/foreach-folder-enumerator.html for some ways of doing it.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply