更新时间:2022-11-20 23:30:11
你必须声明两个SSIS变量
You have to declare two SSIS variables
假设您有一个 List
并且您需要遍历它的项目.以下是如何操作的示例:
Let's say you have a List<string>
and you need to iterate through its items.
Here is a sample how to do it:
创建一个示例脚本任务,该任务将填充col"集合并将User::col"变量添加到任务 ReadWriteVariables 列表中.脚本主体如下:
create a sample script task that will fill the "col" collection and add the "User::col" variable to list of the tasks ReadWriteVariables. The script body would be following:
List<string> col = new List<string>() {"One", "Two", "Three"};
Dts.Variables["User::col"].Value = col;
创建一个 Foreach 循环容器并将其配置为在变量User::Col"上键入From variable enumator".
create a Foreach loop container and configure it to type "From variable enumator" over variable "User::Col".
在 Foreach 容器中创建一个示例脚本任务,演示迭代的消耗(将User::s"添加到任务的 ReadOnlyVariables).脚本主体如下:
create a sample script task within the Foreach container, demonstrating consuming of the iteration (add the "User::s" to task's ReadOnlyVariables). The script body would be following:
string val = (string)Dts.Variables["User::s"].Value;
MessageBox.Show(val);
注意:脚本示例是用 C# 为 BIDS 2008 编写的.
Note: the script samples are written in c# for BIDS 2008.