• 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

    The value generated by the procedure dbo.startdate(0) is returned in the OUTPUT parameter @StartDate.  The value in @Severity would be made available if GetStartDate is execute this way:
    declare @StartDate DateTime, @result int;
    EXEC @result = EXEC GetStartDate @StartDate OUTPUT;
    SELECT @result, @StartDate;

    Does that help?