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?
 
PedroCGDConnect With a Mentor Commented:
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
 
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
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
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
 
PedroCGDCommented:
I'll do an example now..
just a moment...
0
 
PedroCGDCommented:
Improvements!?
0
 
PedroCGDCommented:
Could you please give feedback to this question? Problem solved?!
Regards,
pedro
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.