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
rss2Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

carsRSTCommented:
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.

0
PedroCGDCommented:
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
0
rss2Author Commented:
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
0
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

PedroCGDCommented:
I'll do an example now..
just a moment...
0
PedroCGDCommented:
Here you have...
add the attached package to a SSIS Package, update the strFilename variable in SSIS and the connections.
Helped?
regards
Pedro
SSIS-Interface.JPG
Package-EE133-dtsx.txt
MyPaths.txt
bFile.txt
aFile.txt
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PedroCGDCommented:
Improvements!?
0
PedroCGDCommented:
Could you please give feedback to this question? Problem solved?!
Regards,
pedro
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.