T-SQL Throw Exception

前端 未结 6 1326
孤独总比滥情好
孤独总比滥情好 2020-12-29 01:13

I am facing the famous \'Incorrect syntax\' while using a THROW statement in a T-SQL stored procedure. I have Googled it and checked the questions on StackOverf

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-29 01:26

    This continues to occur in SQL Server 2014.

    I have found that putting the semi-colon at the end of BEGIN helps.

    This approach has the error

    IF 'A'='A'
    BEGIN
       THROW 51000, 'ERROR', 1;
    END;
    

    And this approach does not have the error

    IF 'A'='A'
    BEGIN;
      THROW 51000, 'ERROR', 1;
    END;
    

提交回复
热议问题