Options for formatting your code
Published 11 February 2013
To set formatting options, on the SQL Prompt menu, select Options. The formatting options are all available in the Format group:
To review the effect of any changes you make, use the Preview tab:
- The Sample SQL view shows how an example query would be formatted using the current options.
- The Current Query view shows how the first few lines of the query that is currently active in the editor window of your SQL editing application (eg SQL Server Management Studio) would be laid out using the current options.
Use the Actions page to choose what happens when you run Format SQL.
Selecting UPPERCASE or lowercase will replace any words you have typed with the selected case, and also insert any suggestions using the selected case.
For example, if UPPERCASE is selected:
- If you have already typed
Selectin your query, SQL Prompt replaces the word with
- If you type
Seland then insert SELECT from the suggestions box, SQL Prompt inserts
Selecting Leave as is will leave the case of any letters you have already typed, but insert the remainder of the word using the case of the last typed letter.
- If you type the entire word
Select, SQL Prompt leaves the word exactly as typed.
- If you type
Sel, SQL Prompt will insert
- If you type
SEL, SQL Prompt will insert
Changing the case in pasted code
When you paste code into your query editor, you can apply your preferred case to that code.
- Set the case options for keywords, functions, and data types as required on the Format > Case page of the SQL Prompt Options dialog box.
- Click OK to save these settings.
- In your query editor, select all the lines of code to which want to apply the case.
- On the SQL Prompt menu, select Format SQL.
This will also apply all other format settings (such as indentations, new line settings, and so on) to that code.
Options for formatting new lines and indents in CREATE and ALTER statements.
Options for formatting new lines, parentheses and indents in SELECT, INSERT, UPDATE and DELETE statements.
Options for formatting parts of statements, for example how Boolean and other types of operators should appear.
Commas & parentheses
Options for formatting where commas should appear in your SQL statements (at the end or beginning of lines), and how they should align with other lines of code.
Tabs & wrapping
Options for tabs and spaces and when to wrap lines.
Formatting SQL in your current editor window
To format the SQL code in the current query editor or the highlighted SQL code fragment, do any of the following:
- on the SQL Prompt menu, select Format SQL
- press Ctrl + K + Y (hold down Ctrl and press K then Y)
Saving format settings
You can use styles to save your preferences for formatting code. See Using styles to format your code.