有些Task组件执行完成之后,会产生输出结果,称作Execution Value,例如,Execute SQL Task在执行完成之后,会返回受影响的数据行数。Task组件的Execution Value可以通过属性ExecValueVariable来获取。
属性ExecValueVariable指定存储Execution Value的变量名,属性的默认值是none,表示task的输出结果不会被存储到变量;创建一个变量,并将变量名赋值给该属性,表示在Task执行完成之后,SSIS将Task的输出结果赋值给该变量。
示例,在Execute SQL Task中执行更新语句,获取受影响的数据行总数
update dbo.dt set c1=5
1,创建一个变量VarInt,用于保存更新的数据行数量
2,设置Execute SQL Task的属性ExecValueVariable,选择用户创建的变量User:VarInt
3,执行Package,在Watch调试窗口中查看变量的值
Appendix:
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 |
参考文档:
Have you used the ExecutionValue and ExecValueVariable properties?
作者:
悦光阴
本文版权归作者和博客园所有,欢迎转载,但未经作者同意,必须保留此段声明,且在文章页面醒目位置显示原文连接,否则保留追究法律责任的权利。