T-SQL How to end an IF-ELSE IF-ELSE block

前端 未结 6 1655
野的像风
野的像风 2021-02-12 10:44

When I run the below procedure with the correct parameters so that the -1 value isn\'t returned, none of my DML statements are firing. I\'m guessing that it\'s treating all my D

6条回答
  •  忘了有多久
    2021-02-12 11:22

    Okay you have to use Begin and End in the Else statement as it contains multiple lines of code.

        IF @Code = 'KP'
            SET @stringConcat += 'Y';
        ELSE IF @Code = 'RL'
            SET @stringConcat += 'Z';
        ElSE
        Begin
            -- Return error code and stop processing
            SELECT -1;
            RETURN;
        End
    

提交回复
热议问题