Follow our code layout rules
These rules apply to decorative changes that affect whitespace such as tabs, spaces and line breaks. Nonetheless, it's important to adhere to a standard, to help others understand the intent of code.
So, while SQL Prompt allows us to write code in a format, we find comfortable, we must always apply our standard styling rules1 before sharing code and checking it into source control.
You SHOULD format and analyse your code using SQL Prompt before checking into source control.
You SHOULD configure SQL Prompt with our rule. See SQL Prompt configuration for help with using our standard SQL Prompt config files.
Further reading and information
The Basics of Good T-SQL Coding Style - Simple Talk (red-gate.com )
Beyond Formatting: Improving SQL Code using SQL Prompt Actions | Redgate (red-gate.com )
The Redgate Guide to SQL Server Team-based Development | Redgate (red-gate.com)
Using multiple custom SQL formatting styles in SQL Prompt (red-gate .com)
Aliases
You SHOULD:-
-
Alias ALL table names using the convention AS <alias>.
-
Use meaningful alias names, following our naming conventions (see later in this document.)
-
Qualify each column with the parent table or alias, especially where the parent table is part of a join or subquery.
Code comments
You SHOULD use the code headers provided in SQL Server Management Studio's (SSMS) default templates to comment scripts, stored procedures, functions and the like.
-
In this regard, SQL prompt is necessary to implement the standard ↩