SQL Prompt - 4.0
Learning SQL Prompt - 4.0
Using styles to format your code
A style contains all your preferred settings for formatting SQL code. Saving your formatting options as a style allows you to reapply them to a query at a later date, or share them with other SQL Prompt users so they can use the same conventions for formatting their queries.
Overview: applying a style to your code
- On the Format > Styles page of the SQL Prompt Options dialog box, select the style you want to use from the Styles drop-down list.
Before you apply the style, you can preview how it will lay out the first few lines of your current query - select the Current Query preview tab.
Note: The style is not applied to your code until you specifically choose to apply it in your code editor.
- Click OK to close the SQL Prompt Options dialog box.
- Select the code you want to format in your SQL editor, right-click and click Format SQL.
If you don't select any code, the entire query will be formatted.
Note: SQL Prompt cannot format your query if it contains syntax errors. A message will be displayed to indicate when there are syntax errors.
Choosing a style
From the SQL Prompt Options dialog box, select Format > Styles.

Select a style you have previously created from the Style drop-down list.
An asterisk * next to a style name indicates that some format options currently selected in SQL Prompt do not match those previously saved as this style.
If you close the SQL Prompt Options dialog box and then format the code, it will use the current settings rather than the settings saved in the style.
If the style you want to use has been emailed to you, or is available on your network, you will first need to import it into SQL Prompt. See Importing and exporting styles.
Previewing the effect of the style
There are two ways to preview the effect of applying the current format options to your code:
- 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.
Editing the format settings
See Options for formatting your code.
Applying a style to your code
- Select the style you want to use, then click OK to close the SQL Prompt options dialog box.
- In your query editor, highlight the lines of code you want to format, and do one of the following:
- Press Ctrl + K, Y (hold down Ctrl and press K then Y)
- Right-click and click Format SQL
- On the SQL Prompt 4 menu, select Format SQL
If you don't select any code, the formatting will be applied to the entire query.
Importing and exporting styles
You can share formatting styles with other people. SQL Prompt can export all the format settings as a single file, which can then be imported by another SQL Prompt user. This allows you to ensure consistent conventions within your organisation. See Importing and exporting styles.
Was this article helpful?
SQL Prompt
- SSMS failed to load SQL Prompt add-in 80070002
- No SQL Prompt menu appears in Query Analyzer
- SQL Prompt is showing an old version of my stored procedure (version 3)
- Removing menu items after uninstalling SQL Prompt and SQL Refactor
- A newly-created table exists, but it is not visible in the candidate list (version 3)
- Configuring permissions for SQL Prompt
- Using Intellisense or auto complete with a VS Web project (version 3.5)
- Uninstalling the Visual Studio 2005 add-in
- Unable to cast object of type 'System.DBNull' to type 'System.String' (version 3)
- Suggestions to improve performance for pre-formatted SQL (version 3.9)
- Changing the location of the settings, cache files and snippets folders
- Saving SQL Prompt options (version 3)
- SQL 2008 installation fails with Express Tools rule (version 3.8)
- Add-in failing to load into SQL Server Management Studio on Vista
- Removing SQL Server Management Studio Integration after uninstallation
- Layout SQL Error
- Downgrading to SQL prompt 3.9 from 4.0
- Candidate suggestions being displayed slowly
- SQL Prompt is not showing all linked servers
- Log files
- Refreshing the cache
all SQL products
- Compatibility of Red Gate tools in 64-bit environments
- Application has encountered an error and needs to close
- Error message after installing SQL Toolbelt - The description for Event ID ( 1 ) in Source ( nview_info ) cannot be found.
- Changing the temporary directory used by the installer
- Toolbelt Installer "hanging" while "scanning volumes"
- Login failing with "trusted SQL Server connection" error when using RunAs
all products
- Some Red Gate products identified as containing a trojan by Anti-Virus software
- Activation may fail with Unknown Error -1
- Product uses web help although a CHM file is available locally
- Argument exception resulting from missing environment variable
- Check for updates may fail when used through proxies
- 'Unidentified Publisher' error when repairing or uninstalling
- Licensing activates product as standard edition
- Moving Red Gate software products to another machine
- Red Gate tools log locations
- The application UI opening slowly when there is no internet access
SQL Prompt
- Activating your products
- Activating your products
- Getting help offline
- Customizing SQL Prompt to write SQL code more efficiently
- SQL Prompt 3.xx - reducing memory usage to improve performance
- Using SQL Prompt 4: tips for SQL Prompt 3 users
- SQL Prompt release notes - version 4.xx
- Release notes - version 5.xx
all SQL products
all products
- Red Gate product acknowledgements
- Activating your products
- Activating your products
- Red Gate bundle history
- Check for updates
- Troubleshooting Check for Updates errors
- Current versions
- Deactivating your products
- Installing Red Gate products from the .msi file
- Requesting additional activations
- Serial numbers for bundles
- Reactivating using a different serial number
- Extending your trial
- Finding your serial numbers
- Moving a serial number from one computer to another
- No response received for manual activation
- Licensing and activation resources
- Licensing and activation resources
- Troubleshooting licensing and activation errors
- Licensing and activation FAQs
- Red Gate tools log file locations
- Download old versions of products
- Download product prerequisites & utilities
- Support & upgrades
- Upgrading your software
- Upgrading FAQs

Inserting suggestions
Formatting your code