0

I have the following stored procedure

CREATE PROCEDURE [log].[SP_LogExecutionStep] 
    @ExecutionGUID [uniqueidentifier],
    @ProjectName NVARCHAR(50) = NULL ,
    @PackageName NVARCHAR(255) = NULL ,
    @PackageVersion NVARCHAR(10) = NULL,
    @ParentPackageName NVARCHAR(255) = NULL,
    @ParentExecutionID INT = NULL,
    @ExecutionStatus NVARCHAR(50) = NULL,
    @ExecutionResult NVARCHAR(50) = NULL,
    @ExecutionMessage NVARCHAR(255) = NULL, 
    @ExecutionID INT OUTPUT
AS
BEGIN
    -- Start Logging.
    INSERT INTO log.T_LOG_Execution (ID_ExecutionGUID, LB_ProjectName, LB_PackageName, LB_PackageVersion, LB_ParentPackageName, ID_ParentExecutionId, LB_ExecutionStatus, LB_ExecutionResult, LB_ExecutionMessage, DT_ExecutionStartDate)
        SELECT 
            @ExecutionGUID, @ProjectName, @PackageName, @PackageVersion, @ParentPackageName,
            @ParentExecutionId, @ExecutionStatus, 
            CASE @ExecutionStatus 
                WHEN 'Running' THEN 'In Progress' 
                ELSE @ExecutionResult 
            END, @ExecutionMessage, GETDATE()

    -- Set Output Parameter as the last Identity created to be used for subsequent logging.
    SELECT @ExecutionID = CAST(SCOPE_IDENTITY() AS INT)
END

I am trying to bind the ExecutionID output parameter to an SSIS variable.

My SQL Execute Task details

My calling of the stored procedure

My binding process

I seem to be missing something in my logic as I am getting the following error:

Value does not fall within the expected range

When I tried removing the output parameter route and taking a the result as a result set it works fine.

I appreciate the help

I tried doing it without a output parameter and it works.

My aim is to use the output parameter approach.

3
  • Side note: you should not use the sp_ prefix for your stored procedures. Microsoft has reserved that prefix for its own use (see Naming Stored Procedures), and you do run the risk of a name clash sometime in the future. It's also bad for your stored procedure performance. It's best to just simply avoid sp_ and use something else as a prefix - or no prefix at all! Commented Jun 11, 2024 at 16:51
  • 1
    Your output variable in the SSIS flow is set as LONG but your output parameter from the SP is INT. Not sure if that is the issue. If you do not have to use the OUTPUT parameter and you can just select the value and have it returned that way, then in the SP execute you can select Record set as the output and select single line and map the variable that way. Commented Jun 11, 2024 at 17:20
  • 1
    @Brad that approach worked fine and the data types were INT and LONG and I got no issues. Commented Jun 12, 2024 at 4:03

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.