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 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 the ExecutionValue 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 its Execute 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.

The ExecutionValue property can be defined on the object Task and all tasks have this property. 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.

在Execute SQL Task中,使用该属性指定一个变量,用以接收受影响的数据行数。Returns the number of rows affected by the SQL statement(s).The ExecValue is using the @@ROWCOUNT to assign the value of the variable and absent a @@ROWCOUNT the value returned is -1.

示例 Execute Sql Task的ExecValueVariable 用法

1,design package的ui

Execute Sql Task的sql语句是,属性ExecValueVariable的值是变量varCount

insert into dbo.delay_test
VALUES(1),(2),(3)

insert into dbo.delay_test
VALUES(2),(3)

Task insert Data的sql语句是,传入的参数是User::varCount

insert into dbo.dt_test
values(?)

2,查看结果,第一个Task返回的结果是varCount是2,这个结果实际上是@@RowCount,SSIS在执行语句之后,将@@RowCount赋值到Execute SQL Task 属性ExecValueVariable指定的变量中。

时间: 2024-10-10 12:26:39

Execute Sql Task的ExecValueVariable 用法的相关文章

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 选项卡中,将

[转]SSIS Execute SQL Task : Mapping Parameters And Result Sets

本文转自:http://www.programmersedge.com/post/2013/03/05/ssis-execute-sql-task-mapping-parameters-and-result-sets.aspx#.U18_6PmSxBk A very common scenario in an ETL process is one in which you need to call out to some configuration tables to figure out so

微软BI 之SSIS 系列 - Execute SQL Task 中的 Single Row 与 Full Result Set 的处理技巧

开篇介绍 Execute SQL Task 这个控件在微软BI ETL 项目中使用的频率还是非常高的,也是大部分入门 SSIS 初学者最早接触到的几个控制流控件. 我们通常使用 Execute SQL Task 的场景包含但不止于以下几类: 在从源端加载数据到 Staging 表之前使用 Execute SQL Task 执行一些 Truncate 操作. 执行一些 Log 的插入,更新操作. ETL 过程中的 Merge 语句操作. XML 的输出处理. 关于如何使用 Execute SQL

Execute SQL Task 参数和变量的映射

Execute SQL Task能够执行带参数的SQL查询语句或存储过程(SP),通过SSIS的变量(Variable)对参数赋值.对于不同的Connection Manager,在Task中需要使用不同的符号(Parameter marker)来标记一个参数,并且在Parameter Mapping中设置参数名字(Parameter Name). 在Execute SQL Task Editor中,设置Parameter Mapping的界面如下: Variable Name:变量的名字,变量

Execute Sql Task 的Result DataSet如何返回

Execute Sql Task的Result DataSet 主要有以下四种,当Execute Sql Task返回结果之后,需要使用SSIS Variable 来接收数据. 例子中使用的数据表代码如下 create table dbo.test ( code int, name varchar(10), txt Nvarchar(10) ) insert into dbo.test(code,name,txt) values(1,'a',N'b'),(2,'c',N'd'),(3,'e',N

Execute Sql Task 执行有参数的存储过程

Execute Sql Task 执行有参数的存储过程时,传递参数的方式是不同的,根据使用链接的不同,主要分为两种:OleDB和Ado.Net. create dbo.test (id int) CREATE PROCEDURE dbo.usp_AddItem @id int AS BEGIN SET NOCOUNT ON; insert into dbo.test(id) values(@id) END 1,如果ConnectionType是Oledb,那么使用?代表参数名字,?的序号是从0,

006_SSIS execute sql task 调用存储过程

1.首先在SqlServer中创建存储过程: if OBJECT_ID('usp_t013_inset_process_log') is not null drop procedure usp_t013_inset_process_log go create procedure usp_t013_inset_process_log @execution_id varchar(50), @package_name varchar(50), @machine_name varchar(50), @i

SQL中if exists用法细节

用if exists建表[转] 1 判断数据库是否存在 Sql代码 if exists (select * from sys.databases where name = ’数据库名’) drop database [数据库名]  if exists (select * from sys.databases where name = ’数据库名’) drop database [数据库名] 2 判断表是否存在 Sql代码 if exists (select * from sysobjects w

行转列:SQL SERVER PIVOT与用法解释

转自:http://www.cnblogs.com/lwhkdash/archive/2012/06/26/2562979.html 在数据库操作中,有些时候我们遇到需要实现“行转列”的需求,例如一下的表为某店铺的一周收入情况表: WEEK_INCOME(WEEK VARCHAR(10),INCOME DECIMAL) 我们先插入一些模拟数据: INSERT INTO WEEK_INCOME SELECT '星期一',1000 UNION ALL SELECT '星期二',2000 UNION