Are BEGIN / END keywords required in a stored procedure?

23,514

Solution 1

They are optional.

From MSDN - CREATE PROCEDURE:

From the definition of the command -

AS { [ BEGIN ] sql_statement [;] [ ...n ] [ END ] }

And later on in the page:

{ [ BEGIN ] sql_statement [;] [ ...n ] [ END ] }

One or more Transact-SQL statements comprising the body of the procedure. You can use the optional BEGIN and END keywords to enclose the statements.

Solution 2

As indicated in the CREATE PROCEDURE documentation, they are optional.

{ [ BEGIN ] sql_statement [;] [ ...n ] [ END ] }

One or more Transact-SQL statements comprising the body of the procedure. You can use the optional [emphasis added] BEGIN and END keywords to enclose the statements. For information, see the Best Practices, General Remarks, and Limitations and Restrictions sections that follow.

Personally, I always include them, but that's just me.

Share:
23,514
JJ.
Author by

JJ.

Updated on October 03, 2020

Comments