SQL Prompt 3.5   

Managing Snippets

See Also

Snippets enable you to insert pre-defined code into your query editor. To insert snippet code:

SQL Prompt is pre-configured with default snippets. For example, the ssf snippet inserts a SELECT * FROM fragment; the cdb snippet inserts a CREATE DATABASE statement and places the insertion point after the CREATE DATABASE fragment for you to specify the name of the new database. You can edit or delete the default snippets on the Snippets options page.

You can create your own code snippets, including specifying the position at which SQL Prompt will place the cursor after it has inserted the code snippet.

To manage snippets, on the SQL Prompt menu, click Options, and then click the Snippets tab.

The Snippets tab displays a list of default and custom snippets, listed in alphanumeric order. To sort by category or description, click the column header. You can view the code for a snippet by clicking it.

If you do not want to use TAB to insert snippets, clear Insert snippets without using the candidate list.

By default, the 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.

To restore the default snippets if you have edited or deleted them, click Restore Defaults. This also restores the default settings for the check boxes.

Creating custom snippets

  1. On the Snippets tab of the Options dialog box, click New.
  2. Type a name for your snippet in the Snippet box.

    This is the text that you will type in your query editor window when you want to use the snippet.

  3. Select a Category:

    You can use categories to organize your snippets. The following categories are available:

    • Access Control
    • Administrative
    • Analysis Services
    • Control Flow
    • DDL
    • DML
    • Miscellaneous
  4. 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.

  5. 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.

  6. Click Save.

Editing snippets

To edit a snippet, on the Snippets tab of the Options dialog box, select the snippet that you want to edit and click Edit, or double-click the snippet. Then, on the Snippet Properties dialog box, change the details as required and click Save.

Deleting snippets

To delete a snippet, on the Snippets tab of the Options dialog box, select the snippet that you want to delete and click Delete.

 

 

 


© Red Gate Software Ltd 2007. All Rights Reserved.