I have a 2008 SSIS package that reads a dynamic number of files and loads it into a table. I am using the Foreach File Enumerator that runs a data flow to populate a table. I also have logic to move each file processed into an \archive folder and rename it with a timestamp. I also added some event handling in the case the load errors, in which I store the ErrorDescription into a variable object as an ArrayList in the OnError event, then consolidate the ArrayList descriptions into one big string to send via an email from the OnPostExecute event.
One of the issues I have is that if this becomes scheduled, and there happens to be no files to process in the source directory, the SSIS package will run, but still kicks off the event handling portion, which I do not want it to do. I would like to somehow not make the event handling execute if there are no source files to process so no email is sent out.
I was thinking of creating a variable that counts how many times the Foreach Enumerator runs; if no files exist, then the value would be zero, then I can use that to prevent the email script task being executed. The problem is, I do not know how to increment a variable. I tried creating a script task that takes a variable as the input, but it won't let me use the same one as output.
I'm sure this is pretty easy to do; I just happen to suck and only have about 1.5 days of SSIS experience.