SQL Prompt 9

SQL Code Formatting and Styles

Formatting and styles are all about taking some code and making sure that it is easy to read and understand. Formatting or style changes are 'decorative' changes that affect only whitespace, such as line breaks, tabs and spaces; they do not change the meaning of that code in any way. If we remove all formatting from a piece of code, it will continue to function exactly as before.

SQL Prompt allows us to define custom or built-in styles, where each style (akin to a template), encapsulates a specified set of values for the formatting options that govern how you wish to lay out your SQL code. With a few keyboard strokes (Ctrl K, Ctrl Y; mnemonic "kick yourself"), we run the Format SQL command, which will apply the current Active Style to all code, or selected code, within an SSMS query window. A developer can very quickly view any code in the style they find easiest to read. The team can also create and share a common style, to be applied to all code just before committing it to the shared source control repository. If everyone's code is formatted the same way, it will be much easier for any team member to review another’s code with minimal confusion.

Documentation for SQL Code Formatting and Styles


Additional Resources for SQL Code Formatting and Styles

In addition to this documentation, the Redgate Hub offers the following resources to help you find your way around SQL Code Formatting and Styles, learn how to use it, and adopt best practices :



Didn't find what you were looking for?