1

Using VS (2019) I created an Integration Services Project to code an SSIS package. The goal was to call a Web API from an SSIS package using input variables like username/password/url and so on. I successfully achieved this using Script Task and Dts.Variables and F5/Run to see successful results. What I want to achieve now is to return (like an out parameter) an Id returned to me by the Web API. I want to have this Id returned in the SSMS Results window when I execute the SSIS script in SSMS.

Here is what I have done:

  1. VS > Open dtsx file in Designer and in the "Control Flow" tab, right clicked to add variable:

enter image description here

enter image description here

  1. Right clicked the Script Task I had created and added the variable created above in the ReadWriteVariables section:

enter image description here

  1. Using "Edit Script" to code the Web API call and return a value and set it as follows:

    //MessageBox.Show(id);
    Dts.Variables["User::Id"].Value = Convert.ToInt32(id);

The MessageBox was just to test if the id is returned by the Web API and I get an alert of the "id" when I Run/F5 the SSIS project in Visual Studio. The second line is where I have set the Variable.

  1. I execute the SSIS in using T-SQL in SSMS from an example here:

    Declare @execution_id bigint

    EXEC [SSISDB].[catalog].[create_execution] @package_name=N'ssisWAP.dtsx', @execution_id=@execution_id OUTPUT, @folder_name=N'SSIFolder', @project_name=N'SampleProject', @use32bitruntime=False, @reference_id=Null

    Select @execution_id

    DECLARE @var0 sql_variant = N'username'

    EXEC [SSISDB].[catalog].[set_execution_parameter_value] @execution_id, @object_type=20, @parameter_name=N'Username', @parameter_value=@var0

    DECLARE @var1 sql_variant = N'password'

    EXEC [SSISDB].[catalog].[set_execution_parameter_value] @execution_id, @object_type=20, @parameter_name=N'Password', @parameter_value=@var1

    EXEC [SSISDB].[catalog].[start_execution] @execution_id

The above executes properly, calling the API and an out @execution_id is shown in Result window. But no sign of the variables User::Id I created earlier. Is it possible to show that value in the Result window? If not, is there a way to see that the data in that variable in SSMS after SSIS execution (even from designer)?

I already had a look at this post: Returning Output Paramters or Variables From SSIS Script Task / Script Component

where the solution is to use "Execute SQL Task" and "pass" the variable into a procedure. This I guess is one way to do it but I want to just get the Id in the return when I execute the script as shown above.

Any help will be appreciated. Thanks

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.