[转]SSIS 的ExecValueVariable

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.
时间: 2024-08-29 03:54:24

[转]SSIS 的ExecValueVariable的相关文章

Execute Sql Task的ExecValueVariable 用法

ExecValueVariable属性指定一个变量,接收Task的ExecutionValue,在下游组件中可以引用该变量. Set the name of the custom variable that receives 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 i

SSIS Execute SQL Task 用法

Execute Sql Task组件是一个非常有用的Control Flow Task,可以直接执行SQL语句,例如,可以执行数据更新命令(update,delete,insert),也可以执行select查询语句,返回结果集,结果集可以是一行,也可以是多行. 一,General 选项卡 1,返回结果集(Result Set) None:表示不返回结果,在执行Update,delete或insert命令时,使用该选项: Single row:返回单行结果,可以在Result Set 选项卡中,将

微软BI 之SSIS 系列 - Precedence Constraint 详解优先约束的使用

开篇介绍 Precedence Constraint 优先约束 - 在控制流中使用,用来链接控制流中各种 Task,Container,并且要求满足一定的条件才能执行相关联的 Task 或者 Container. 比如下图中,第一个 Execute SQL Task 叫做 Precedence-Executable 优先可执行任务,而Script Task 由于在关联箭头的下游,所以它叫做 Constrained-Executable 受约束可执行任务.关联箭头的上游任务自然先执行,关联箭头下方

批量导出存储在msdb库的SSIS包

use msdb   go IF OBJECT_ID('msdb.dbo.usp_ExportSSISPkgs') IS NOT NULL     DROP PROCEDURE dbo.usp_ExportSSISPkgs;    go CREATE PROCEDURE dbo.usp_ExportSSISPkgs   @exportPath NVARCHAR(2000)='D:\temp\'    AS    BEGIN DECLARE @pkgData XML, @pkgName NVARC

SSIS 学习之旅 序章 和 简介

SSIS 学习之旅目录: 第一章: SSIS 学习之旅 第一个SSIS 示例(一) 第二章: SSIS 学习之旅 第一个SSIS 示例(二) 第三章: SSIS 学习之旅 数据同步 第四章: SSIS 学习之旅 FTP文件传输-FTP任务 第五章: SSIS 学习之旅 FTP文件传输-脚本任务 第六章: SSIS 学习之旅 FTP访问类 SSIS是Microsoft SQL Server Integration Services的简称,是生成高性能数据集成解决方案,是Microsoft BI 解

第十五篇 Integration Services:SSIS参数

本篇文章是Integration Services系列的第十五篇,详细内容请参考原文. 简介在前一篇,我们使用SSDT-BI将第一个SSIS项目My_First_SSIS_Project升级/转换到SSIS 2012.在这一篇,我们将探讨SSIS变量的姊妹:SSIS参数.我们将展示参数配置,通过包参数管理动态属性值,以及在SSIS包执行期间参数是如何配置和使用的.首先在SSDT-BI打开转换过的My_First_SSIS_Project,如图15.1所示:图15.1My_First_SSIS_P

第十三篇 Integration Services:SSIS变量

本篇文章是Integration Services系列的第十三篇,详细内容请参考原文. 简介在前一篇我们结合了之前所学的冒泡.日志记录.父子模式创建一个自定义的SSIS包日志记录模式.在这一篇,我们将升级我们的解决方案为SQL Server 2012 Integration Services,演示SSIS变量,变量配置和表达式管理动态值.在前面的练习中我们已经使用过变量,但我们没有深入学习,这一篇,我们将关注SSIS变量.…………一旦安装好,你可以设置主题颜色,工具->选项->环境->常

SSIS:捕获修改了的数据

获取修改了的数据一般有三种方式: 1.使用一个datetime列 缺点:是并不是每个表都会有个‘修改日期’字段来让你判断行是否修改过 使用实例可以参考我之前的文章:SSIS: 使用最大ID和最大日期来增量更新表 2.MSSQL 自带的功能CDC (change data capture) CDC使用 SQL Server Agent把变更的数据写到另外一个表中. 缺点: 如果数据库变动频繁会占用大量的磁盘空间 1) 启用CDC 注意:只有开发板和企业版提供CDC功能 USE [Adventure

变量在SSIS包中的使用

2010~2011年经常使用SSIS包采集加工数据,后来换了工作就很少使用.最近又开始用那玩意采集数据,努力回想之前是怎样操作的,网上各种找各种纠结.趁这次使用记录下日常操作步骤,以备以后不时之需. --环境SQL Server2012.VS2010(安装数据库时默认会安装)下载示例数据库AdventureWorks2012 1 CREATE DATABASE [AdventureWorks2012] ON 2 (FILENAME=N'D:\SQL2012\MSSQL11.SQL12\MSSQL