Link to home
Start Free TrialLog in
Avatar of rss2
rss2

asked on

SSIS foreach loop file enumerator - loop through a specific order of the filenames

Hi Experts,

I have an SSIS package written in 2008, and I would like to use the foreach to read flat files from a directory one by one.

However, I want to pull the files through the foreach loop in a very specific order. It's not alphabetical.. One of the files has to go first, then the others.

Other than having that one file to go first before the foreach loop, and then process the others, is there a way in that one foreach loop to specify the order of the files?

For instance, can I read the filenames into a recordset, then have the foreach loop read from that recordset in a specific order?

Thank you!
rss2
Avatar of carsRST
carsRST
Flag of United States of America image

I would take your approach - i don't think you can guarantee the order..

1.  Create a script to import the file names in the folder to a new table.  

2.  Use an "Excecute SQL Task" to put the pull from that table, in your specific order, in to an "object" data type variable.

3.  Using the foreach - iterate through in your order.

yes you can save the files (pathname + filename) into a recordset and read it from a for each loop!
Do you need an example?
regards,
Pedro
Avatar of rss2
rss2

ASKER

Thank you, yes, I would be greateful for an example.

Also, do you know how I can re-order the rows in the recordset, so i can specify the order of the filenames coming out of the recordset into the foreach loop?

Thank you!

rss2
I'll do an example now..
just a moment...
ASKER CERTIFIED SOLUTION
Avatar of PedroCGD
PedroCGD
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Improvements!?
Could you please give feedback to this question? Problem solved?!
Regards,
pedro