码迷,mamicode.com
首页 > 其他好文 > 详细

[转]SSIS 的ExecValueVariable

时间:2015-09-14 13:42:25      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:

The ExecutionValue execution value property and it’s friend ExecValueVariable are a much undervalued feature of SSIS, and many people I talk to are not even aware of their existence, so I thought I’d try and raise their profile a bit.

The ExecutionValue property is defined on the base object Task, so all tasks have it available, but it is up to the task developer to do something useful with it. The basic idea behind it is that it allows the task to return something useful and interesting about what it has performed, in addition to the standard success or 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 is a very useful feature, something people often want to capture into a variable, and start using the result set options to do. Unfortunately we cannot read the value of a task property at runtime from within a SSIS package, so the ExecutionValue property on its own is a bit of a let down, but enter the ExecValueVariable and we have the perfect marriage.

The ExecValueVariable is another property exposed through the task (TaskHost), which lets us select a SSIS package variable. What happens now is that when the task sets the ExecutionValue, the interesting 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 put simply if the ExecutionValue property value is of interest, make sure you create yourself a package variable and set the name as the ExecValueVariable. Have  look at the 3 step guide below:

1 Configure your task as normal, for example the Execute SQL Task, which here calls a stored procedure to do some updates.

技术分享

2 Create variable of a suitable type to match the ExecutionValue, an integer is used to match the result we want to capture, the number of rows.

技术分享

3 Set the ExecValueVariable for the task, just select the variable we created in step 2. You need to do this in Properties grid for the task (Short-cut key, select the task and press F4)

技术分享

Now when we execute the sample task above, our variable UpdateQueueRowCount will get the number of rows we updated in our Execute SQL Task.

I’ve tried to collate a list of tasks that return something useful via the ExecutionValue and ExecValueVariable mechanism, but the documentation isn’t always great.

Task ExecutionValue Description
Execute SQL Task

Returns the number of rows affected by the SQL statement or statements.

File System Task Returns the number of successful operations performed by the task.
File Watcher Task Returns the full path of the file found
Transfer Error Messages Task Returns the number of error messages that have been transferred
Transfer Jobs Task Returns the number of jobs that are transferred

Transfer Logins Task

Returns the number of logins transferred
Transfer Master Stored Procedures Task Returns the number of stored procedures transferred

Transfer SQL Server Objects Task

Returns the number of objects transferred
WMI Data Reader Task Returns an object that contains the results of the task.          Not exactly clear, but I assume it depends on the WMI query used.

[转]SSIS 的ExecValueVariable

标签:

原文地址:http://www.cnblogs.com/ljhdo/p/4806885.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!