question

Ved avatar image
Ved asked

For each loop enumerator in SSIS

I am using ForEach loop container to read files from a source folder .before execution there are two files in the folder but at run time another file is dumped to the same folder. I want that file should also be read within that execution process. So please tell me the method to implement the same using SSIS.
sqlssisserver
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Mrs_Fatherjack avatar image
Mrs_Fatherjack answered
You need to ensure that in the Collection tab of the Foreach Loop Editor that under Files you select *.* and not explicitly select the filename or type of file. That should do it.
5 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Ved avatar image Ved commented ·
actually the task is reading the entire directory and if at the time of execution new file is added to the directory then it should read that file also.
0 Likes 0 ·
Mrs_Fatherjack avatar image Mrs_Fatherjack commented ·
I agree, are you saying that it's not?
0 Likes 0 ·
Ved avatar image Ved commented ·
yes, when package is executing and if the new file is added to directory, then it skips that file
0 Likes 0 ·
Mrs_Fatherjack avatar image Mrs_Fatherjack commented ·
It sounds like the files are being copied before the new file is in the directory. I would suggest you run the package one step at a time to see exactly what's going on.
0 Likes 0 ·
Ved avatar image Ved commented ·
yes, i have seen that and it is skipping the newly added file.
0 Likes 0 ·
Naveen Kumar avatar image
Naveen Kumar answered
once the package execution is started, it will go through the number of files so the files which are being added at the time of execution will be ignored.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Pavel Pawlowski avatar image
Pavel Pawlowski answered
I would go by a For Loop Container which will loop until a variable is set to fale (in the beginning true). Then having another variable with list of processed files and variable of files to process. With each loop of the For Loop Container you could use the script task to dump the list of files in the directory. Then the files not contained in the list of processed files, you add to the processed files and also to the list of files to be processed. If the list of files to be processed is empty, the variable to control the For Loop Container will be set to False to exit the loop execution. Next action will be a ForEach loop to process the list of files to be processed. ![alt text][1] [1]: /upfiles/Loop.png
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

cbrammer avatar image
cbrammer answered
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.