DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE
SITE SEARCH SQLUSA.com HEADLINES NEWS
SQL E/BOOKS   SQL 2014 PROGRAMMING   DOWNLOADS
SCRIPTS SQL 2005 SQL 2008 ARTICLES
SQL JOBS TWITTER FORMAT VIDEOS
How to comment a stored procedure?

The following is the guideline and an example for stored procedure documentation:

1. Don't document anything obvious to other database developer

2. Document anything not obvious

AdventureWorks2008 stored procedure header block documentation example:

-- AdventureWorks2008 stored procedure

-- sys.sp_addextendedproperty is an option to add documentation

CREATE PROCEDURE uspGetBillOfMaterials

      @StartProductID [int],

      @CheckDate [datetime]

/*

 *  uspGetBillOfMaterials stored procedure using a recursive query (BOM_cte)

 *  to return a multi-level bill of material for the specified ProductID

 *

 *  @StartProductID input parameter for the stored procedure uspGetBillOfMaterials.

 *  Enter a valid ProductID from the Production.Product table.

 *

 *  @CheckDate input parameter for the stored procedure uspGetBillOfMaterials

 *  used to eliminate components not used after that date. Enter a valid date.

 */

AS

BEGIN

SET NOCOUNT ON;

-- Recursive CTE to locate parts up-to depth of 25

WITH [BOM_cte]([ProductAssemblyID], [ComponentID], [ComponentDesc], [PerAssemblyQty],

     [StandardCost], [ListPrice], [BOMLevel], [RecursionLevel])

-- CTE name and columns

AS (

.....

 

Related articles:

ONLINE INSTANT T-SQL FORMATTER

Programming Flow Overview, Code Format and Commenting your Code

Aaron Bertrand: My stored procedure "best practices" checklist

 

Exam Prep 70-461
Exam 70-461
DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE