How to manage SQL snippets

You can use the Snippets Manager to open a number of customizable code blocks to choose from. Snippets Manager enables you to:

  • Create new or custom SQL snippets
  • Modify the predefined snippets
  • Group snippets in a folder
  • Delete the selected snippets or folders
  • Sort snippets in the tree by shortcut, in ascending or descending order
  • Add, update, or delete literals of the snippet
  • Change the file location of the snippet

To access the Snippets Manager, navigate to the SQL Complete menu and select Snippets Manager.

Snippets Manager

To create a SQL snippet:

1. On the Snippets Manager toolbar, click New Snippet.

2. In the Title and Description fields, specify the name and description of the snippet respectively.

3. In the Shortcut field, enter a name for the snippet shortcut. The shortcut will be used to insert the snippet into the code. In addition, it will be displayed in the suggestion box.

4. In the Literals field, define the literals (placeholders) of the code snippet that can be updated.

5. To keep the changes, click Save.

The default path to the snippet is C:\ProgramData\Devart\dbForge SQL Complete\Snippets. If you want to set a new file location, click More Options icon More Options in the Location field.

To modify the snippet, select the snippet you want to update in the snippets tree, modify the parameters, and click Save.

To organize snippets into folders, click New Folder on the toolbar, specify the folder name, and move snippets to the folder or create new ones.

To delete the snippet or folder, select the element you want to remove, click Delete on the toolbar, and confirm the deletion.

Snippet placeholders

SQL Complete provides the following predefined placeholders, which deliver multiple replacement points for the same parameter:

Placeholder Description
$CARET$ Specifies the position in the text where the cursor should be moved after the snippet has been edited.
$DATE$ Inserts the current date in the format yyyy-mm-dd.
$TIME$ Inserts the current time in the format hh:mm:ss.
$LOGIN$ Inserts the login from which the user is connected to the SQL Server.
$USER$ Inserts the name of the user who is currently connected to the SQL Server.
$DB$ Inserts the name of the database to which the current query tab is connected.
$SERVER$ Inserts the name of the server you are currently connected to.

When a snippet is invoked, the appropriate text/value will be inserted into the placeholder.

User literals

Each code snippet has an individual set of User Literals that can be created, updated, or deleted.

To create a user literal:

1. In the tree, select the snippet for which you want to create the literal.

2. Under the Literals section, click Add.

3. In the Edit Literal pop-up that opens, enter the following information, and then click Ok:

  • Name: A name of the user literal.
  • Default value: A default value for the variable that will be displayed in the snippet in the query window. The default value can be modified after inserting a snippet in the query window.
  • Description: A short description of the snippet. You can view it when hovering over the literal in the User section of the Snippets Manager.

4. To keep the changes, click Save.

To modify the user literal, click Edit and follow the steps from the Create a user literal procedure.

To remove the user literal, click Remove and then click Save on the toolbar.

Snippets Manager

Want to Find out More?

Overview

Overview

Take a quick tour to learn all about the key benefits delivered by dbForge SQL Complete for SQL Server.
All Features

All features

Get acquainted with the rich features and capabilities of the SQL Complete in less than 5 minutes.
Request a demo

Request a demo

If you consider employing the SQL Complete for your business, request a demo to see it in action.
Ready to start using dbForge SQL Complete for SQL Server?