SSIS- Set Multiple variables via a single SQL task

后端 未结 3 706
-上瘾入骨i
-上瘾入骨i 2021-02-09 07:21

I\'m trying to set multiple variables to the result of an SQL Query that returns a single row with multiple columns. The SQL statement is in the format of:

SELEC         


        
3条回答
  •  误落风尘
    2021-02-09 07:26

    Create one stored procedure with four output parameters:

    CREATE SP_data(
      @x INT,
      @a int OUTPUT,
      @b int OUTPUT,
      @c int OUTPUT 
      @d int output
    )
    AS
      SELECT top 1 
        @a = a,
        @b= b, 
        @c  = x + y,
        @d= @d  
    FROM tablename
    WHERE Switch = @x
    

    in the Execute SQL Query in the parameter mapping tab create four output parameters

    the execute the proc

    EXEXCUT SP_data 1,? OUTPUT,? OUTPUT,? OUTPUT, ? OUTPUT
    

提交回复
热议问题