• Sean Lange (2/11/2013)


    DON'T use things you don't need, like the BEGIN and END for the proc itself - completely unneeded and doing nothing but cluttering up the screen.

    Actually begin and end serve a VERY valid purpose within a proc. They very clearly define the beginning and the end. Yes it probably appears as a little overkill but it forces you to indent the code that is the body of the proc making it more clear in a large script what is what.

    That's FALSE. Since you can have an unlimited number of BEGIN/END combinations in a proc, they clearly don't define the beginning and the end of the proc, even if you want them to (and you can't prevent someone from later adding code before the first BEGIN or after the last END, which is reason enough to NEVER consider "BEGIN" and "END" as "defining the beginning/end of a proc").

    The block created by BEGIN/END adds restrictions on variable use, etc., outside that block, so you're just inviting errors with an unnecessary BEGIN/END.

    Furthermore, indenting unconditional code in a proc makes no sense and wastes space. The required:

    GO

    CREATE PROCEDURE

    within a script full of procs will inherently delineate the start and end of procs. Too many people over-indent as it is, making the code very hard to read.

    SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.