Link to home
Start Free TrialLog in
Avatar of Alex A
Alex A

asked on

SSIS: Foreach Loop Container

Hi, there are many data files in the folder and I'd like to know the order they will be processed. I am using Foreach Loop Container. Does anyone know how it loops through the files, in alphabetical order or ... ?
Avatar of DcpKing
DcpKing
Flag of United States of America image

I think that it will order by filename, but I haven't tested it very much!  Try putting some files in named a.txt, b.txt, c.txt, etc., but don't add them to the folder in that order. Then see what you get.

To be certain of your order you could read then in in a foreach loop, placing them into a table. Then read the table in the proper order into an Object Variable, and have a ForEach loop read the object variable and not directly from the disk.

hth

Mike
Avatar of Jim Horn
The order of file loading is not predictable.  

If you require an ordered loading, I'd use the first ForEach loop to get all file names and insert them into a table.  
Then do a SQL Task to select that list, ordered by however you wish.
Then, go through a loop to set the source to that path-file, and load.
ASKER CERTIFIED SOLUTION
Avatar of ValentinoV
ValentinoV
Flag of Belgium 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