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

前端 未结 6 1653
野的像风
野的像风 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:24

    If you want both SELECT -1 and RETURN to be inside the ELSE you'll have to use a BEGIN / END block. Now only the SELECT -1 is inside the else branch.

    So you need

    ELSE
      BEGIN
        SELECT -1;
        RETURN;
      END
    

提交回复
热议问题