SQL Prompt 6

Managing snippets

You can use SQL Prompt snippets to insert pre-defined code into your query editor. To view the list of snippets, on the SQL Prompt menu, select Snippet Manager.

The Snippet Manager dialog box displays a list of snippets, sorted alphabetically. To sort by description, click the Description column header.

Click on a snippet to view the code for that snippet in the Code box.

The snippet code is inserted at the indentation level of your SQL code at the point of insertion.

Creating a snippet from code you've typed

You can create a snippet from code you've typed into the query editor.

Select the code so that it's highlighted, then right-click and select Create Snippet.

The Create New Snippet dialog box is displayed, so you can edit the snippet name or text if required.

The default snippet name is created automatically from the initial letters of the selected text. You can edit this if you want to use a different name.

Creating a new snippet

  1. On the SQL Prompt menu, select Snippet Manager.
  2. Click New.
  3. In the Snippet box, type the text that will insert the snippet.
  4. Optionally, type a short description of your snippet in the Description box.
    The description helps you to identify a snippet if you are unsure of the snippet name. You can leave the Description box blank if required.
  5. Type or paste the SQL code in the Code box.

    In your snippet code you can specify:

  6. Click Save.

Using placeholders

You can use the following placeholders in snippet code:


Inserts the current date.

You can specify a custom date format, for example $DATE(MM/dd/yyyy)$.  


Inserts the current time.

You can specify a custom time format, for example $TIME(HH:mm:ss)$.

$USER$Inserts the name of the connected user.
$PASTE$Inserts the contents of the clipboard.
$MACHINE$Inserts the name of machine running SQL Prompt.

Specifies the cursor position when the snippet is inserted.

For example, SELECT $CURSOR$ FROM places the cursor after SELECT.

$SERVER$Inserts the name of the connected SQL server.
$DBNAME$Inserts the name of the connected database.



Selects a block of the snippet text.

For example, $SELECTIONSTART$SELECT TOP 100 * FROM Table1$SELECTIONEND$ is inserted as:

Editing snippets

In the Snippet Manager dialog box, select the snippet you want to edit and click Edit, or double-click the snippet. Then, in the Edit Snippet dialog box, change the details as required and click Save.

Sharing snippets

You can share your snippets with other SQL Prompt users by storing them in a shared folder (a network share, SkyDrive, or Dropbox, for example).

To use a shared folder:

  1. On the SQL Prompt menu, select Snippet Manager.
  2. In the Snippets list, right-click any snippet, and then click Locate on Disk:

    Your snippets folder is opened in Windows Explorer.

    Snippets are stored as XML files with the .sqlpromptsnippet file extension.

  3. In the snippets folder, copy the snippet files you want to share.
  4. Open the shared folder you want to use (a network share, SkyDrive, or Dropbox, for example), and paste the snippets into it.
  5. In the Snippet Manager, under Snippets folder, browse to the location of your shared folder:

 Other SQL Prompt users can use the same set of snippets by changing their snippets folder to the shared folder.

To restore the snippets folder to the SQL Prompt default, click Restore default.

Getting more snippets

Snippet repository on GitHub

If you're using Git, you can clone a repository of useful snippets contributed by Gaurav Vohra.

Thanks Gaurav!

tSQLt snippets for SQL Test

If you're using SQL Test, you can download a set of useful snippets from the tSQLt website (under Other Downloads).

The snippets include pre-defined code for:

  • test creation and execution
  • assertions
  • isolating dependencies

Didn't find what you were looking for?