ST003 - Entire procedure body not enclosed within BEGIN...END rule is stupid

Consider this temporary stored procedure code:

CREATE OR ALTER PROCEDURE #ST003_EXAMPLE AS
BEGIN
  PRINT 'Great';
END;

-- some debug after END...
THROW 50000, 'Really!', 1;

GO -- Separated statement for easy executing whole window from SSMS

EXECUTE #ST003_EXAMPLE;


This example will of course throw error. Why? Because procedure (and trigger) body is whole statement (in this example separated by GO). NOT BEGIN..END subpart. This can lead to serious errors.


Answers

Sign In or Register to comment.