help needed in SQL server stored procedure

  • Which line is the error on? You should have two END statements, one to match the BEGIN, and another to match the CASE. I don't see the second END clause, so I don't know what code is before it. Most likely, there is a syntax error or incomplete statment right before that second END.

  • yeah it works adding an END statement it works..

    Thanks

  • Also, you are erroneously using the table alias "et", without actually declaring it. You need to do one of the following:

    1. Declare et: "FROM earned_transaction AS et"

    2. Use the full table name: "AND earned_transaction.quarter = @prevQuarter"

    or 3. Don't specify a table at all: "AND quarter = @prevQuarter"

  • K thanks, but there seems to be problem, i tested this query, it never goes in to else 'Absent' part, means when there is no transaction it has to go there, bit it doesnt..

    Please help

  • Is it returning NULL instead? You could:

    SET @lastQuartRewardState = ISNULL(@lastQuartRewardState, 'Absent')

    ... at the very end.

  • Yes it works, thanks

Viewing 6 posts - 16 through 22 (of 22 total)

You must be logged in to reply to this topic. Login to reply