How to use SQL code text auto-replacements

In this article, the use of text auto-replacement feature in ApexSQL Complete will be described.

ApexSQL Complete is a SSMS and VS add-in that speeds up 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 users to speed up coding assigning and auto-replacement token, for common typing mistakes (e.g. Adress -&rt; Address), frequently used SQL commands (e.g. Create table), frequently used objects, etc. Note these are case sensitive.

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

The Enable auto–replacement command

The auto-replacement feature can be enabled by pressing the Ctrl+Shift+Alt+J shortcut.

Creating and managing auto-replacements

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

The Manage auto-replacements command

In the Manage auto-replacements window, it can be added new, edited or deleted an existing auto-replacing token by selecting the token in the window and clicking the New, Edit, or the Delete button.

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

Assign auto-replacement to a database object

An auto-replacement token can be assigned to an object in a database. Select an object in the Object Explorer or Server Explorer pane, right click it, and from the ApexSQL Complete context menu, select the Assign auto-replacement command to open the Auto-replacement window:

The Assign auto-replacement command

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

The Auto-replacement window

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

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 the cp token is assigned to the Create procedure statement, type the cp in the query window, press the Space key and it will be replaced with the Create procedure statement:

Before:

USE [AdventureWorks2014]
GO
cp

After:

USE [AdventureWorks2014]
GO
CREATE PROCEDURE 

If there are 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