【问题标题】:SSIS - how to transform a Recordset as a result of an "Execute SQL Task" into a List<string>SSIS - 如何将记录集作为“执行 SQL 任务”的结果转换为 List<string>
【发布时间】:2015-03-01 10:08:23
【问题描述】:

从 SSIS 包中的“执行 SQL 任务”步骤获得结果,如何将结果 (RecordSet) 转换为 List ? (sql脚本的结果:1个nvarchar列)

第 1 步:“执行 SQL 任务”, 脚本:“从 MyTable 中选择名称”, ResultSet:“完整结果集”,将“0”映射到变量“User::Names”

第 2 步:?

第 3 步:使用 List 类型的变量“User::NameList”,其中包含从第一行开始在脚本中选择的所有值。

【问题讨论】:

  • 您能edit您的问题并添加您拥有的相关代码吗?当有一些代码可以开始时,读者更容易找到答案。

标签: c# sql list ssis recordset


【解决方案1】:
 public void Main()
    {
        var dt = new DataTable();

        new OleDbDataAdapter().Fill(dt, this.Dts.Variables["User::Names"].Value);

        var list = dt.Rows.OfType<DataRow>().Select(i => i[0].ToString()).ToList();

        this.Dts.Variables["User::NameList"].Value = list;

        this.Dts.TaskResult = (int)ScriptResults.Success;
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-12-27
    • 1970-01-01
    • 1970-01-01
    • 2013-08-26
    • 1970-01-01
    • 2020-01-11
    • 1970-01-01
    相关资源
    最近更新 更多