SQL Prompt
Latest version: 5.3
Notes & articles
Customizing SQL Prompt to write SQL code more efficiently
SQL Prompt speeds up the writing of SQL code by offering a list of database objects and SQL statements to be inserted, based on the context of what you type in your query editor.
This article explains how you can further speed up the writing of your code, and customize the code completion behavior, by setting various options in SQL Prompt:
- Qualify column names with the table name
- Qualify database object names with the schema (owner) name
- Assign aliases automatically
- Create snippets to insert predefined blocks of code
All these settings are available in the SQL Prompt Options dialog box. When you have changed the settings you want, click OK to save them and close the dialog box.
To display the SQL Prompt Options dialog box
From the SQL Prompt menu, for example in SQL Server Management Studio, select Options:

Qualifying column names with the table name
You can save time when writing SQL by setting SQL Prompt to add the table name to each column you insert; this means you don't have to type the table name each time.
When you select a column from the candidate list

SQL Prompt inserts the code as follows:
SELECT [AddressLine1] FROM [Address]
You may want the column name to always include the table name as part of its definition:
SELECT [Address].[AddressLine1] FROM [Address]
To specify that SQL Prompt should always insert column names
- Display the SQL Prompt Options dialog box.
- Select the Inserted Candidates tab, then select Formatting.
- Select the Qualify column names check box.

Qualify object names with the owner name
You can save time when writing SQL by setting SQL Prompt to add the owner name to each object you insert; this means you don't have to type the object name each time.
When you select a database object (for example, a view or a table) from the candidate list, SQL Prompt inserts the code as follows:
SELECT * FROM [Address]
You may want the object name to always include the owner name as part of its definition:
SELECT * FROM [dbo].[Address]
To specify that SQL Prompt should always insert object names
- Display the SQL Prompt Options dialog box.
- Select the Inserted Candidates tab along the top of the dialog box, then select the Formatting page from the left.
- Select the Qualify object names check box.

Assigning aliases automatically
You can specify that SQL Prompt automatically assigns an alias to a table or view when you first reference it in a query. SQL Prompt inserts the alias every time you reference the table or view; this means you do not have to type the alias manually, and reduces key presses.
SQL Prompt uses the first letter of the table or view name to create the alias:
SELECT a.[AddressLine1] FROM [dbo].[Address] AS a
Whenever that object is referred to in the query, the alias will be used.
SQL Prompt uses two letters as the alias when the table or view name comprises two words separated by a hyphen, underscore or by the use of a different case. For example:
SELECT AT.[Name] FROM [Person].[AddressType] AS at
To automatically insert an alias for a table or view
- Display the SQL Prompt Options dialog box.
- Select the Auto Insert tab, then select Aliases from the left.
- Select the Enable alias assignment check box.

There are a number of options you can set to configure how aliases are inserted into your code:
- When Include AS in alias definition is selected, SQL Prompt creates the alias using the AS keyword. Clear the check box if you do not want SQL Prompt to include the AS keyword when it assigns aliases.
- When Learn aliases when typing is selected, if you assign a different alias to a table or view name, SQL Prompt remembers the alias you assigned. For example, if SQL Prompt assigns the alias c to the table Contact, you can overwrite the c with a different alias.
- When Learn aliases when opening files or pasting text is selected, SQL Prompt learns aliases from SQL statements that you have pasted into your query editor window or from SQL that you have loaded from a file. You are recommended to clear this option if you are working with large scripts.
Using snippets
A snippet inserts a block of code into your query editor when you type the snippet name. For example, typing
atac
and pressing ENTER inserts the following code:
ALTER TABLE | ALTER COLUMN
This snippet is provided by default with SQL Prompt. To view the list of default snippets or to create your own snippets, use the SQL Prompt Options dialog box:
- Display the SQL Prompt Options dialog box.
- Select the Snippets tab.
The Snippets page lists all the default snippets available in SQL Prompt in alphanumeric order. To sort by category or description, click the column header.

If the snippet you want is not in the list, you can create your own snippet. To create a snippet:
- Click New.
- Type a name for your snippet in the Snippet box. The snippet name is the text that you will type in your query editor window when you want to use the snippet.
- Type or paste the SQL code in the Code box.
To specify the insertion point at which you want the cursor to be placed when the snippet is inserted, use the variable $CURSOR$. For example:SELECT $CURSOR$ FROM
places the insertion point after SELECT.
- Click Save.
Customizing how snippets are inserted
By default, to insert snippet code, you type the snippet name into the query editor then press the TAB key. You can set some options for how the code inserted.
To insert snippets without using the candidate list
If you want to select the snippet code from the candidate list, rather than insert it using the TAB key, clear the Insert snippets without using the candidate list check box.

When you type a snippet, a preview of the code for the selected snippet will be displayed in the Schema panel. Press ENTER to insert the snippet code.

To insert snippets without using the current indentation level
By default, snippet code is inserted at the indentation level of your SQL code at the point of insertion:

If you do not want the snippet code to be indented, clear the Insert snippet at current indentation level check box.

Snippet code will be inserted without being indented:

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

Using SQL Prompt