本文介绍了如何为“foreach"使用列表集合在 SSIS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 如果变量是 SSIS 包中的 List 类型,如何将 foreach 与for each from variable enumator"一起使用.how to use foreach with "for each from variable enumator" if variable is of List<> type in SSIS packages.推荐答案你必须声明两个SSIS变量You have to declare two SSIS variables集合变量(For each 枚举器的来源)一项的变量(在枚举器中使用)假设您有一个 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:在 SSIS 变量窗口中创建名为col"的变量,键入object"创建名为s"的变量,输入string"创建一个示例脚本任务,该任务将填充col"集合并将User::col"变量添加到任务 ReadWriteVariables 列表中.脚本主体如下:in SSIS variables window create variable named "col", type "object"create variable named "s", type "string"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);在 BIDS 中按 F5 执行示例.它应该显示三个对话框,文本为一"、二"、三".注意:脚本示例是用 C# 为 BIDS 2008 编写的.Note: the script samples are written in c# for BIDS 2008. 这篇关于如何为“foreach"使用列表集合在 SSIS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-14 13:32