How to use SQL code text auto-replacements

In this article we will describe how to use the text auto-replacement feature in ApexSQL Complete.

ApexSQL Complete is a free SSMS and VS add-in that speeds up your coding, and improves productivity using features such as: auto-completing SQL keywords and code fragments, SQL snippets, auto inserting statements, text auto-replacement, and more.

ApexSQL Complete’s text auto-replacement feature allows you to speed up your coding assigning an auto-replacement token, for common typing mistakes (e.g. Adress -&rt; Address), your frequently used SQL commands (e.g. CREATE TABLE), frequently used objects etc. Note these are case sensitive.

The autoreplacement feature is not enabled by default, so to enable it choose the Enable autoreplacement command under the ApexSQL Complete menu:

You can also enable the auto-replacement feature by pressing the Ctrl+Shift+Alt+J shortcut.

Creating and managing auto-replacements

To customize your auto-replacements you can use the Shift+Alt+R shortcut, or choose the Manage auto-replacements command under the ApexSQL Complete menu:

In the Manage auto-replacements dialog you can add new, edit, or delete an existing auto-replacing token by selecting the token in the dialog and clicking the New, Edit, or the Delete button.

To edit an existing auto-replacement token, select the token in the dialog edit and click the Save button.

Assign auto-replacement to a database object

You can assign an auto-replacement token to an object in a database. Select an object in the Object Explorer pane and right click, and from the ApexSQL Complete context menu, select the Assign auto-replacement command to open the Auto-replacement dialog:

In the Auto-replacement dialog object’s name will be automatically inserted in the With field:

Type the text of an auto-replacement token for a selected database object in the Replace this text field:

Using the auto-replacement tokens in ApexSQL Complete

To use a created token just type the assigned text and press Space or Enter and it will be replaced by the assigned SQL statement or an object name

For example, if you assigned the “cp” token to the CREATE PROCEDURE statement type the “cp” in the query window, press Space and it will be replaced with “CREATE PROCEDURE”

Before:

USE [AdventureWorks2014]
GO
cp

After:

USE [AdventureWorks2014]
GO
CREATE PROCEDURE 

If you have more tokens in the query window they will be replaced in the whole script:

Before:

The script before token replacement

After:

The script after token replacement

February 24, 2015