The ExecutionValue property can be defined on the object Task and all tasks have this property. Its up to the developer to do something useful with this. The purpose of this property is to return something useful and interesting about what it has performed along with standard success/failure result.
The best example perhaps is the Execute SQL Task which uses the ExecutionValue property to return the number of rows affected by the SQL statement(s). This could be a useful feature which you may often want to capture into a variable and using the result to do something else. We cann't read the value of a task property at runtime from SSIS but we can use ExecValueVariable to get it.
The ExecValueVariable property exposed through the task which lets us select a package variable. When the task sets the ExecutionValue, the actual value is copied into the variable we set on the ExecValueVariable property and a variable is something we can access and do something with. So if you are interested in ExecutionValue property then make sure you create a package variable and set the name as the ExecValueVariable.
Below are the steps to implement this:
STEP1:
Create a new package and add below variable.
STEP2:
Drad and drop Execute SQL Task and set the properties as per your requirement. I am using below query in SQLStatement to update Employee table:
UPDATE [TestHN].dbo.Employee
SET [Basic] = [Basic]*2
WHERE [Basic] < 5000
This query updates 4 records.
STEP3:
Set the ExecValueVariable with User::ExecutionValue variable as shown below:
STEP4:
Drag and drop Script Task to display the result of ExecValue variable. Now Execute the package.
Here is the list of few tasks that return something useful via the ExecutionValue and ExecValueVariable:
Task | Description of ExecutionValue |
---|---|
Execute SQL Task | Returns the number of rows affected by the SQL statement(s). |
File System Task | Returns the number of successful operations performed. |
File Watcher Task | Returns the full path of the file found. |
Transfer Jobs Task | Returns the number of jobs transferred |
Transfer Error Messages Task | Returns the number of error messages transferred. |
Transfer SQL Server Objects Task | Returns the number of objects transferred. |
Nice artice, thanks for sharing.
ReplyDelete