for each loop container how to stop after a particuar number of items in the container
I am using for each loop container to go thru files in a folder I have 1000s of files in the folder. I want to process only 500 at a time how can i tell the package to stop after processing only 500 files at a time Thankssohairzaki
September 5th, 2011 2:16pm

What you might have to do is, within your foreach, is have a script component that can reset your "Files" expression in your enumerator configuration to be something that will cause the loop to stop after 500. For example if the Files specification is *.TXT to begin with, the script component could reset this to something like "*.nomatch" which will cause it to not find any more files. I haven't tested this and I'm not sure if the enumeration of files would get reloaded when you change the wildcard match. But maybe you can experiment and come up with something. Tom Overton
Free Windows Admin Tool Kit Click here and download it now
September 5th, 2011 3:20pm

You can use a WMI data reader to list files in the directory, use following WMI query: Select * From CIM_DataFile Where Drive = 'C:' and Path = '\\temp\\' and Extension = 'txt' Following post describe how to consume results from WMI query: http://agilebi.com/jwelch/2007/09/05/using-the-wmi-data-reader-in-ssis/ If you need to run additional tasks, it is easy to convert script data source to 'for loop' container.
September 5th, 2011 6:15pm

I set the variable myfiles to null but the script task that does that keeps running even after I reach 500 limit.sohairzaki
Free Windows Admin Tool Kit Click here and download it now
September 5th, 2011 7:22pm

Here is an easy example: http://www.bimonkey.com/2009/07/do-while-until-loops-in-ssis/Arthur My Blog
September 5th, 2011 7:36pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics