When creating a stored procedure, is the BEGIN / END block used and intended?
eg,
CREATE PROCEDURE SPNAME AS SELECT * FROM TABLE
against.
CREATE PROCEDURE SPNAME AS BEGIN SELECT * FROM TABLE END
As stated in the CREATE PROCEDURE documentation , BEGIN / END is optional:
{[BEGIN] sql_statement [;] [... n] [END]}One or more Transact-SQL statements containing a procedure. You can use the optional BEGIN and END Keywords to enclose statements. For more information, see Recommendations, General Comments, and Limitations and Limitations that follow.
{[BEGIN] sql_statement [;] [... n] [END]}
One or more Transact-SQL statements containing a procedure. You can use the optional BEGIN and END Keywords to enclose statements. For more information, see Recommendations, General Comments, and Limitations and Limitations that follow.
As a personal preference, I always turn them on.
. , BEGIN TRY - END TRY BEGIN CATCH - END CATCH, .
BEGIN TRY
END TRY
BEGIN CATCH
END CATCH
- . , .
, , BEGIN END ( ).
BEGIN
END
. , BEGIN/END.
BEGIN END , .
:
CREATE PROC dbo.sproc(@v varchar(10)) AS RETURN -1
CREATE FUNCTION dbo.fun(@v varchar(10)) RETURNS INT AS RETURN 1