• macbaze72 - Thursday, December 21, 2017 4:04 PM

    This code works, but I don;t understand it.  The part I need some clarification is on the Return @Severity. Why would that not be Return @StartDate?  As it is written it return the results of dbo.startdate().

    ALTER PROCEDURE GetStartDate(
    @StartDate Datetime OUTPUT
    )
    AS
    DECLARE
        @Severity int

    SET @Severity = 0

    IF @StartDate IS NULL
        SET @StartDate = dbo.startdate(0)

    RETURN @Severity

    DECALRE @StartDate DateTime
    EXEC GetStartDate @StartDate OUTPUT
    SELECT @StartDate

    Thanks
    Everett

    Because @StartDate is the output parameter. In the beginning of the stored procedure it's declared as an output parameter and when executing the stored procedure, you are capturing the output parameter. Output parameters are explained in the documentation for Create Procedure - so it's not like it's easy to find.
    CREATE PROCEDURE (Transact-SQL)

    If you haven't worked with them much, you can find other posts and examples from other sites if you search on: output parameter in stored procedure

    Sue