1

我需要使用 SQL SELECT 的结果,它应该返回一个 ID 数组,以便在我的 foreach 循环中遍历它。我对SSIS很陌生。我创建了执行 SQL 任务,连接到数据库并写入

SELECT ID FROM TABLE

然后我创建了 Script Task 并将这两个组件与 Constraint 连接起来。但我不知道如何将 SQL 任务的结果传递给脚本任务中的对象。

4

1 回答 1

2

您正在寻找的典型模式是这样的:

控制流

1. In execute SQL you need to:
a. Assign the connection
b. Add your SQL Statement
c. Change Result Set to Full Result Set
d. Map the result set to an Object type variable

2. In Foreach
a. Change enumerator to ADO Enum
b. Assign your variable from #1
c. Map a variable to the interation

在此处输入图像描述

****EDIT****
3. Change out data flow for script task
a. Pass in iteration variable
b. in script create the URL as a string
c. use webclient to connect to web service


string url = @"https://www.blah.com? ID=" + 
             Dts.Variable["variable"].Value.ToString();

WebClient wc = new WebClient();
string result = wc.DownloadString(url);

4. Now you have to do something with that result
于 2019-12-10T14:14:00.737 回答