Format SQL
Use the Formatter to modify the layout of SQL in the Editor, including inserting a header block, adding or removing extra lines, and changing the case for keywords.
To preview the look and layout of the available formatting styles, go to Tools | Options | Editor | Formatter. See Formatter Options for more information.
To format SQL
- In the SQL Editor, click the drop-down arrow beside and select a formatting style. Or select Editor | Format Code and select a style.
- Then click to apply the style to the contents of the Editor window.
- To format a partial statement, select the SQL you want to format and click to apply the specified style.
Additional Details
- You can click in other editor windows to format code. The style currently specified in the SQL Editor (or in the Options dialog) is applied.
- You can create a new custom template to use to format code in Tools | Options | Editor | Formatter. See Formatter Options for more information.
- You can also specify custom formatting options for the available templates in Tools | Options | Editor | Formatter.
- You can change or view the location where the formatting templates are stored in Tools | Options | Editor | Formatter.
- To automatically format SQL you send from the Object Explorer to the SQL Editor, go to Tools | Options | Explorer | General and select Automatically format generated SQL. See General Explorer Options for more information.
Related Topics
About Editing SQL