我创建了一个SSIS包,可以将文件导入表格(足够简单)。 我有一些变量,在服务器,数据库,导入文件夹等配置文件中设置了一些变量。在运行时我想传递文件名。这是通过使用dtexec的存储过程完成的。当通过配置文件设置参数时,它也可以在过程中设置所有参数并使用\ Set语句传递它们(如下所示)。当我尝试将config-version与设置参数动态组合时,我得到一个错误,指的是在设计时设置的config-files路径。
是否有人遇到过此问题并找到解决方案?
关心弗雷德里克
DECLARE @SSISSTR VARCHAR(8000),
@DataBaseServer VARCHAR(100),
@DataBaseName VARCHAR(100),
@PackageFilePath VARCHAR(200),
@ImportFolder VARCHAR(200),
@HandledFolder VARCHAR(200),
@ConfigFilePath VARCHAR(200),
@SSISreturncode INT;
/* DEBUGGING
DECLARE @FileName VARCHAR(100),
@SelectionId INT
SET @FileName = 'Test.csv';
SET @SelectionId = 366;
*/
SET @PackageFilePath = '/FILE "Y:\SSIS\Packages\PostalCodeSelectionImport\ImportPackage.dtsx" ';
SET @DataBaseServer = 'STOSWVUTVDB01\DEV_BSE';
SET @DataBaseName = 'BSE_ODR';
SET @ImportFolder = '\\Stoswvutvbse01\Application\FileLoadArea\ODR\\';
SET @HandledFolder = '\\Stoswvutvbse01\Application\FileLoadArea\ODR\Handled\\';
--SET @ConfigFilePath = '/CONFIGFILE "Y:\SSIS\Packages\PostalCodeSelectionImport\Configuration\DEV_BSE.dtsConfig" ';
----now making "dtexec" SQL from dynamic values
SET @SSISSTR = 'DTEXEC ' + @PackageFilePath; -- + @ConfigFilePath;
SET @SSISSTR = @SSISSTR + ' /SET \Package.Variables[User::SelectionId].Properties[Value];' + CAST( @SelectionId AS VARCHAR(12));
SET @SSISSTR = @SSISSTR + ' /SET \Package.Variables[User::DataBaseServer].Properties[Value];"' + @DataBaseServer + '"';
SET @SSISSTR = @SSISSTR + ' /SET \Package.Variables[User::ImportFolder].Properties[Value];"' + @ImportFolder + '" ';
SET @SSISSTR = @SSISSTR + ' /SET \Package.Variables[User::DataBaseName].Properties[Value];"' + @DataBaseName + '" ';
SET @SSISSTR = @SSISSTR + ' /SET \Package.Variables[User::ImportFileName].Properties[Value];"' + @FileName + '" ';
SET @SSISSTR = @SSISSTR + ' /SET \Package.Variables[User::HandledFolder].Properties[Value];"' + @HandledFolder + '" ';
-- Now execute dynamic SQL by using EXEC.
EXEC @SSISreturncode = xp_cmdshell @SSISSTR;
答案 0 :(得分:0)
假设除了User :: ImportFileName之外的所有变量都在配置文件中设置,以下内容应该有效:
DECLARE @SSISSTR VARCHAR(8000),
@PackageFilePath VARCHAR(200),
@ConfigFilePath VARCHAR(200),
@SSISreturncode INT;
@FileName VARCHAR(100)
SET @FileName = 'Test.csv';
SET @PackageFilePath = '/FILE "Y:\SSIS\Packages\PostalCodeSelectionImport\ImportPackage.dtsx" ';
SET @ConfigFilePath = '/CONFIGFILE "Y:\SSIS\Packages\PostalCodeSelectionImport\Configuration\DEV_BSE.dtsConfig" ';
--now making "dtexec" SQL from dynamic values
SET @SSISSTR = 'DTEXEC ' + @PackageFilePath + @ConfigFilePath;
SET @SSISSTR = @SSISSTR + '/SET "\Package.Variables[User::ImportFileName].Properties[Value]";"' + @FileName + '" ';
-- Now execute dynamic SQL by using EXEC.
EXEC @SSISreturncode = xp_cmdshell @SSISSTR;
与您的代码的不同之处是: