Possible Duplicate:
When do I need to use Begin / End Blocks and the Go keyword in SQL Server?
Example:
CREATE PROCEDURE DoSomething
AS
BEGIN
SET NOCOUNT ON;
-- Insert lots of statements in here, including other stored procedures.
END
Do you need the BEGIN and END? Does it make ANY difference if you have them or not?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With