The naming convention for variables and constants is as follows:

1.  Program Structure

The following should be the templates used in T-SQL source code files.

Any T-SQL source file should have a file header of the following format (Header) followed by the body of the procedure. Since SQL server doesn’t support the concept of Packages the only type of header is as follows:

/*
**  (C) <Year>, Deutsche Bank Group

**  Name  :  (name of the package/procedure/function)

**  Description :

**  Author  :

**  MODIFICATION  HISTORY :
**  The history  of changes should be in chronological sequence

Date       Name of the Proc/ Func       Author        Reasons for Change

[Comments by Version control system will be included in this block].
[The position of the same depends on the version control software and projects].
*/

Some general rules to be followed for functions / procedures.

  • The calling procedure/function should always have to check the   return status and proceed with further processing.
  • For example, the following statement should not be used

Insert into table_one select * from table_two;

The select * statement should not be used because, the statement would be invalid in case the structure of the table changes. So the columns have to be explicitly mentioned.

1.1 Indenting

Tabbing is used for indenting. Statement blocks used with the following statements are indented one tab stop from the corresponding statements.

  • Loops and
  • Conditional Statements.

1.2  Spacing

A single space should be placed before and after all operators.  A single space should also be placed after the comma of each argument in function parameter lists.

1.3  Comments

  • Comments should be placed at the beginning of scripts. Comments at the beginning of functions/procedures should describe the valid values for parameters and what the possible return codes are.
  • Global and Local variable declarations should also contain comments that identify their usage.
  • Comments should be placed at the place of modification. In case of a change request, change request number also has to be placed.