SSIS获取执行Sql任务结果集对象 [英] SSIS Getting Execute Sql Task result set object

查看:23
本文介绍了SSIS获取执行Sql任务结果集对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个执行 sql 任务项,它从存储过程中获取多行数据.

I have an execute sql task item and it is getting multiple rows of data from a stored proc.

在变量表下声明了一个变量ObjShipment,并在结果集下使用以下信息对其进行赋值:

Declared a variable ObjShipment under the variable table and assigned it under the Result set with the following info:

Result Set:    Full result set
Result Name:   0
Variable Name: User::ObjShipment

我编写了一个脚本任务,其中 ObjShipment 变量分配给了 ReadOnly,我想知道如何检索其中的数据?

I have written a script task with the ObjShipment variable assigned to ReadOnly an am wondering how to retrieve the data within it?

存储过程返回多行,如 Id、ItemId、DateCreated..,但是如果我只对 ItemId 感兴趣,我该如何检索它们?由于它返回多行,因此可能有多个 ItemId.

The stored proc returns multiple rows like Id, ItemId, DateCreated.., but how do I retrieve them say if I am only interested in the ItemId? And since it returns multiple rows there could be more than one ItemId.

我是 ssis 的新手,任何帮助将不胜感激!

I am new with ssis any help would be appreciated!

推荐答案

所以一般来说,您使用 SSIS 包中的对象变量作为 For Each 容器的枚举器.

So generally speaking you use Object variables within an SSIS package as the Enumerator of a For Each container.

  1. 创建一个 For Each 循环容器.
  2. 将 Enumerator 设置为For Each ADO Enumerator".
  3. 将源变量设置为 User::ObjShipment.
  4. 在变量映射"选项卡中将对象中的每一列分配给它自己的变量.
  5. 在 For Each Loop 容器中,使用这些变量执行您想要的任何操作:将它们插入数据库、执行查找和审核等.

如果您要使用脚本任务,那么您只需要

If you are going to use a Script Task, then you all need to do is

DataTable dt = new DataTable();
OleDbDataAdapter oleDa = new OleDbDataAdapter();
oleDa.Fill(dt, Dts.Variables["User::objShipment"].Value);

然后像使用任何旧的 DataTable 一样使用 dt.

And then use dt like any old DataTable.

这篇关于SSIS获取执行Sql任务结果集对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆