我创建了一个存储过程来在目录中执行ssis包,并在运行时动态设置包参数。然后,我创建一个作业步骤,以使用操作系统(CMDEXEC)命令来运行dtexec实用程序。代码如下:
ALTER PROCEDURE [Administration].[prc_Exec_LoadbenefitStatement_SSIS_TEST1]
@Destination varchar(250),
@FinancialFile varchar(250),
@StaticFile varchar(250),
@StatementType varchar(15),
@ExternalID varchar(20),
@SourceSystemID varchar(20)
AS
DECLARE @jid as uniqueidentifier
BEGIN TRANSACTION
SET NOCOUNT ON;
DECLARE @statement varchar(2000)
BEGIN
SET @statement = 'dtexec /ISServer "\SSISBD\AFFS\KhanyaStatements\Khanya_LoadBenefitStatement.dtsx" /SERVER "XXXXX\SQL01"'
SET @statement = @Statement + ' /Par "Destination";' + @Destination
SET @statement = @Statement + ' /Par "FinancialFile";' + @FinancialFile
SET @statement = @Statement + ' /Par "StaticFile";' + @StaticFile
SET @statement = @Statement + ' /Par "StatementType";' + @StatementType
SET @statement = @Statement + ' /Par "ExternalID";' + @ExternalID
SET @statement = @Statement + ' /Par "SourceSystemID";' + @SourceSystemID
END
DECLARE @jname varchar(128)
SET @jname = cast(newid() as char(36))
EXEC msdb.dbo.sp_add_job
@job_name = @jname,
@enabled = 1,
@category_name = 'KhanyaStatements_SSIS',
@delete_level = 3,
@job_id = @jid OUTPUT
EXEC msdb.dbo.sp_add_jobserver
@job_id = @jid,
@server_name = 'XXXXX\SQL01'
EXEC msdb.dbo.sp_add_jobstep
@job_id = @jid,
@step_name = 'Execute SSIS',
@subsystem = 'CMDEXEC',
@proxy_name = 'pr_KhanyaStatements',
@command = @statement
DECLARE @returncode tinyint
EXEC @returncode = msdb.dbo.sp_start_job
@job_id = @jid
SELECT @returncode
SET NOCOUNT OFF;
COMMIT TRANSACTION
我创建了凭据,代理和作业类别。当我执行proc时,返回代码为0表示成功但我可以清楚地看到包没有执行。请帮忙吗?