At times I have seen in SSIS forums people ask about the way they can know the number of records updated by a query or deleted by a query in an Execute SQL Task in control flow. Even I replied at times that its not possible(in a direct manner), until I read about the property ExecValueVariable.
MSDN says: “The name of the custom variable that contains the execution result for the task. The default value of this property is none, which indicates that the result is not set to a variable in the package.
The TaskHost exposes the ExecutionValue property through the ExecValueVariable property. The task uses the ExecutionValue property to provide optional, supplemental information about the results of execution. The ExecValueVariable property allows the user to map theExecutionValue that the task returns to any variable that is visible to the task. The package could then use the value that is returned as one of the criteria for determining the next task to run in the control flow. For example, if a task deletes rows from a table as part of itsExecute method, the task might return the number of rows deleted as the ExecutionValue. Clients of the task could then use this value to define expressions in precedence constraints between tasks.”
Though I would advise you not to use this variable to know the outcome of a task or decide the flow of the control flow(use precedence constraint in stead). Again if the update or insert is done in a stored procedure it will not be saved to the variable instead you would get “0”. This does work for plain Select statement as well.
So the bottom line is when you have an Execute SQL Task and you wish to get the number of records inserted or deleted from a simple query you could use this property.
Tags: SSIS, Execute SQL Task, MSBI, ExecValueVariable, #BI, #SSIS, BRH,