您可以采用两种不同的方法。
第一个是作为 user569711 概述并使用 ForEach Enumerator 并调用您现有的存储过程。这样做的好处是您的行为应该与您当前所经历的完全一样,并且您的测试只需要专注于确保 SSIS 包选择正确的文件。
第二种是使用 SSIS 的开箱即用功能来处理导入 BLOB 类型。
控制流
您将需要根据您的方法定义 1 到 2 个变量。两者都是字符串数据类型。我创建了SourceFolder
和CurrentFileName
. 前者定义了文件的来源并在任一方法中使用。后者在 ForEach 循环容器中用于捕获“当前”文件。

数据流
要使数据流正常工作,您需要将完全限定的文件名列表添加到管道中。最简单的方法是使用脚本转换,作为源并将其添加到所有满足您条件的文件(*.xml)中。

Foreach 循环容器
像这样配置
收藏

变量映射

执行 SQL 任务
如此配置


脚本源
此任务会将可用文件添加到数据流中。次要注意,这将遍历与我们配置 Foreach 的方式不同的子文件夹。这是对第三个参数(或省略)的简单更改,使其仅位于顶层。
识别您的变量,使其在脚本任务中可用

添加适当的输出列。您的长度可能因您的环境而异。

脚本在这里
using System;
using System.Data;
using System.IO;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
{
public override void CreateNewOutputRows()
{
string fileMask = string.Empty;
string sourceFolder = string.Empty;
fileMask = @"*.xml";
sourceFolder = this.Variables.SourceFolder;
foreach (string fileName in Directory.GetFiles(sourceFolder, fileMask, SearchOption.AllDirectories))
{
Output0Buffer.AddRow();
Output0Buffer.FileName = fileName;
Output0Buffer.SourceName = "Dataflow";
}
}
}
导入列转换
像这样配置

在此处记下 ID

将该 ID 绑定到具有名称的列

OLE DB 目标
配置。不支持快速加载选项。


参考
关于使用导入列转换的好帖子