Rules of SQL formatting – SQL code commenting

In this article we’ll give some tips on T-SQL code commenting and improving your productivity using ApexSQL Refactor’s Comments feature. ApexSQL Refactor is a free SQL Server and Visual Studio SQL Formatting add-in with nearly 200 formatting options.

The main purpose of comments is to document our code and write descriptions of what code is doing.

February 12, 2014

Rules of SQL formatting – Commas and spacing in T-SQL

This article describes some possibilities of formatting commas and spacing in T-SQL using ApexSQL Refactor, a free SQL formatter with nearly 200 SQL formatting options.

Formatting commas in T-SQL

Commas in T-SQL are used to format numbers, as list-separators, and value separators. When commas are used as separators, there is no specific rule for placing commas at the end of a line or at the beginning.

February 5, 2014

SQL Formatting standards – joins, lists, structure, operations

The first part of the series – SQL Formatting standards – Capitalization, Indentation, Comments, Parenthesis, explains the importance of having clean SQL. In short, deciphering someone else’s code is time-consuming. Clean and neat SQL code can be read faster; SQL reviewing and troubleshooting is more efficient; joint development efforts are more effective; handing off projects from one team to another is smoother than for inconsistently written SQL.

As there are neither style nor standards to format SQL, it’s up to the team to create its own set of formatting standards. Here are some recommendations to format joins, value lists, code structure, arithmetic, comparison and logical operations.

April 4, 2013

SQL Formatting standards – Capitalization, Indentation, Comments, Parenthesis

Nobody likes to read a wall of text, even when it’s just plain text. When it comes to reading code, the problem is even bigger. Code can have different formatting styles, which could make your job either easier or more difficult. It can make code difficult to decipher and understand. A clean and neat SQL is read faster than an inconsistently written SQL; SQL reviewing and troubleshooting is more efficient; joint development efforts are more effective; handing off projects from one team to another is smoother.

How to make your SQL readable so that it is enough just to skim through the code and get the general idea

It’s the SQL formatting that makes the difference.

April 4, 2013