• A very good thread, thanks again Andy!

    I do like to include a header, for many of the same reasons others have mentioned. I've included a sample of a typical one I've been using for the past 9 months that's worked out pretty well when either our new developer or I have to go back and look at a procedure.

    In light of Andy's article, I think I can start eliminating the name of the procedure in the first line of the comments 🙂

    I like to include a brief description of what the procedure is for and any "interesting" things going on inside that might not be obvious from a first or second reading.

    Then I list any parameters and what they mean or any limitations on them.

    I usually list table aliases, and finally, I include a "depends on" section -- but now I'm wondering if I should add a section of what depends on the SP.

    I don't put a list of variables, because I try to create variables that are self-explanatory by their names and context and use functions to aid in clarity, such as

    SET @Qtr1StartDate = FirstDayOfMonthYearAgoThisMonth(@RunDate)

    SET @Qtr2StartDate = DateAdd(qq, 1, FirstDayOfMonthYearAgoThisMonth(@RunDate))

    I think I can begin leaving off the "modifications" comments - you guys are right - that's easier and better done via source control.

    Best regards,

    SteveR

    /* **************************************************************************************

    spRptDoDByCutoffBasis

    Usage: EXEC dbo.spRptDoDByCutoffBasis 42782, '4/11/02', 'S', 'F'

    Description: Outputs the PXZX and Units/1000 for the immediate past year

    and the previous year, figured from the RunDate parameter.

    The FromDate of the immediate past year is 1 year prior to

    the first day of the RunDate month. The ToDate of the

    immediate past year is the last day of the month preceding

    the RunDate. The corresponding parameters for the "LastYear"

    dates are 1 year earlier

    Parameters: @SavedReportID - PK of record in table WH_SavedReports - used

    to provide lists of Bases included, Departments included, etc.

    @RunDate - used to calculate From and To dates for immediate past year

    and the previous year

    @RegularOrSpecialCount - 'R' for PRZX, 'S' for PSZX. Defaults to 'R'

    @UseStartOrFinishDate - whether data is grabbed based on Start ('S') or

    FinishDate ('F')

    Table Aliases: c = WH_1Processes_xxxx

    d = WH_ParentCodes

    p = WH_Procedures

    Depends On: Function dbo.spGetRegularAndSpecialCounts (therefore requires SQL Server 2000 or higher)

    By : S. Rosenbach 09/12/2002

    Modified : S. Rosenbach 09/23/2002 - added ability to run using either Start or Finish Date

    S. Rosenbach 10/03/2002 - modified definition of running as Finish to mean finished by

    the Run Date AND Posted by the current date.

    *********************************************************************************** */