且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 SSIS SQL 任务中使用标量值 tSQL 函数设置变量

更新时间:2022-03-10 01:35:39

我最初尝试使用带有返回方向的参数映射,但那是错误的.

I initially went down the path of trying to use a Parameter Mapping with a direction of Return but that was incorrect.

相反,我按所示配置了我的执行 SQL 任务.我的 ResultSet 是一个单行".我的 SQLStatement 只是SELECT dbo.MyDB_GetJobID()"

Instead, I have my Execute SQL Task configured as shown. My ResultSet is a "Single Row". My SQLStatement is simply "SELECT dbo.MyDB_GetJobID()"

在结果集选项卡中,由于这是 Single Row 的 ResultSet 类型,因此我们为每列提供了一个基于零的序数系统的映射.

In the result set tab, since this is a ResultSet type of Single Row, then we provide a mapping per column with a zero based ordinal system.

这是一个演示将结果分配给变量 User::SingleRow 的示例.您可以忽略 Other,因为我试图通过参数映射"选项卡使用它.

This is an example demonstrating the result being assigned to the variable User::SingleRow. You can ignore Other as I was trying to make it work with via the Parameter Mapping tab.