我正忙于设置一个 SSIS 包,该包采用平面文件并将其内容加载到临时表中。从那里它需要获取该文件的文件名并将其与其中一行数据一起保存到另一个表的字段中。我通过使用执行存储过程的执行 SQL 任务来加载数据。此过程将文件名作为输入参数(只是为了将其写入该表)...我在执行 SQL 任务之前添加了一个脚本任务,该任务执行以下操作:
public void Main()
{
string inputFolder;
string fileName;
inputFolder = Dts.Variables["SourceFolder"].Value.ToString();
// MessageBox.Show(inputFolder);
string[] foundFiles = null;
foundFiles = System.IO.Directory.GetFiles(inputFolder);
if (foundFiles.Length > 0)
{
fileName = foundFiles[0];
Dts.Variables["ProcessedFileName"].Value = System.IO.Path.GetFileName(fileName);
// MessageBox.Show(fileName);
// MessageBox.Show(System.IO.Path.GetFileName(fileName));
}
Dts.TaskResult = (int)ScriptResults.Success;
}
“ProcessedFileName”变量是 SSIS 包中的全局变量,也是“SourceFolder”变量。
我使用直接输入执行设置的执行 SQL 任务:
DECLARE @StoredProcedure varchar(100) = ?;
DECLARE @ProcessedFileName varchar(100) = ?;
EXEC ? ?;
参数映射到变量 StoredProcedure 和 ProcessedFileName。
问题是当我运行它时它告诉我“没有为一个或多个必需参数提供值”。为什么会这样?