使用存储过程执行SSIS pacakge

时间:2016-01-19 09:14:30

标签: sql-server stored-procedures ssis

我想使用存储过程执行SSIS包,我正在使用SQL Server 2014,我的SP上出现错误。

代码:

Alter procedure ExamplePackage
@output_execution_id bigint output
as
begin
declare @execution_id bigint  
DECLARE @BranchErrorMessage nvarchar(100)
DECLARE @ContractDateErrorMessage nvarchar(100)
DECLARE @ContractNoErrorMessaget nvarchar(100)
DECLARE @CreatedBy bigint
DECLARE @DatabaseConnection nvarchar(100)
DECLARE @DSA_IDErrorMessage nvarchar(100)
DECLARE @DSACodeErrorMessage nvarchar(100)
DECLARE @FileDiscriminator nvarchar(100)
DECLARE @FileName nvarchar(100)
DECLARE @FinAmountErrorMessage nvarchar(100)
DECLARE @IsDeleted bit
DECLARE @ProductCodeErrorMessage nvarchar(100)
DECLARE @ProductErrorMessage nvarchar(100)
DECLARE @SourceFilePath nvarchar(100)
DECLARE @SubProductCodeErrorMessage nvarchar(100)
DECLARE @TFlexTypeId bigint
DECLARE @WorkRequestId bigint

exec ssisdb.catalog.create_execution 
@BranchErrorMessage = 'Branch code does not exist in Branch Master'
,@ContractDateErrorMessage = 'ContractDate is Empty',
@ContractNoErrorMessaget='ContractNo is Empty',
@CreatedBy='2' ,
@DatabaseConnection='Data Source=SAMDK12120010;User           ID=sa;Password=jgd123$;Initial      Catalog=TataCapitalTest6_May;Provider=SQLNCLI11.1;Auto Translate=False;',
 @DSA_IDErrorMessage='DSA Id is invalid',
  @DSACodeErrorMessage='DSACode is Empty',
  @FileDiscriminator='IntermediateError',
   @FileName='ss',
    @FinAmountErrorMessage='FinAmount is Empty',
     @IsDeleted='False',
     @ProductCodeErrorMessage='ProductCode is Empty',
     @ProductErrorMessage='Product code/SubProduct code does not exist in      Product Master',
      @SourceFilePath='D:\Vinoth Kannan\Package    new\ODS_CLMS_DAILY_DISBURSED_CASES_PLBL_17012016-15.01.txt',
     @SubProductCodeErrorMessage='SubProductCode is Empty',
     @TFlexTypeId='20',
       @WorkRequestId='200',
     @package_name = 'DisbursePLBLCaseIntermediateImportPackage.dtsx'
      ,@execution_id = @execution_id output
      exec ssisdb.catalog.start_execution 
     set @output_execution_id = @execution_id
      print @output_execution_id
          end

我收到错误:

  

sg 201,Level 16,State 4,Procedure ExamplePackage,Line 0
  过程或函数'ExamplePackage'需要参数'@output_execution_id',这是未提供的。

SP通话示例:

Exec ExamplePackage

1 个答案:

答案 0 :(得分:1)

使用参数

调用程序
DECLARE @output_execution_id bigint
EXEC ExamplePackage @output_execution_id OUTPUT

在您的过程中,您必须先调用create_execution来获取执行ID。 然后设置你的参数,最后用执行ID调用start_execution。

在此学习https://msdn.microsoft.com/en-us/library/ff878034.aspx