I ran into a very odd situation with an SSIS package I have been working with.
I have a foreach loop that contains a data flow task which executes for every record in a recordset object populated prior to the loop.
In the dataflow task I have an ADO.NET source, a lookup, and finally a destination script component. The script component initializes a datatable in PreExecute, adds each row from the input, and post sends the datatable as a table valued parameter to a stored procedure. The lookup task is set up to only send non-matching rows to the script component.
The odd situation is that I found when all rows on the lookup were matched the script component was still being executed with 0 rows sent to it. This resulted in an error in the stored proc as I was only ever expecting it to be called when the script component received more than 0 rows. I have corrected the issue in the stored proc itself by first doing a check that there is actually data passed in.
In other packages I have very similar situations with destination script components set up after lookups where 0 records get passed in, and have not seen this behavior occur there – the only difference is that they’re not within foreach loops.
So, I’d really like to know, for future reference, if it is the expected behavior of an an SSIS script component that it would execute with 0 rows passed in?
PreExecuteandPostExecutemethods will execute even if there are no rows to redirect from the followingLookup Transformationoutputs to theScript Componentconfigured asDestinationcomponent within Data Flow Task.Make sure that the package that you believe is working differently than the one not working is configured in the same manner.