How to use SQL snippets

A SQL code snippet is a fragment of reusable code or statement that can be added or edited by a user. To view the snippets, navigate to the SQL Complete menu and select Snippets Manager.

Invoke snippets

To invoke snippets, use one of the following options:

  • Suggestion box: Press Ctrl+Space and scroll down the suggestion list - snippets will be listed after keywords.
  • Snippet shortcuts: Start typing a snippet shortcut and view the content of the corresponding snippet. For instance, ssf will show SELECT * FROM.

Snippet shortcut

Commit snippets

To commit a snippet, do either of the following:

  • Press Enter when the code snippet is shown in the suggestion box.
  • Press Tab when the suggestion box is closed and the statement expansion tags are shown.

After inserting snippets, it is possible to configure the parameters of the snippet. For instance, you inserted the CTE (Common Table Expression) snippet:

To configure the parameters, in the CTE name placeholder, enter “query” and then press Tab to enter the schema name. You can enter only initial letters like “hr”, and thanks to the CamelHumps feature, “HumanResources” will be automatically selected in the suggestion list.

Press Tab to enter the table name. You can type the first symbols like “emp” and then choose an “Employee” table from the list, press the Enter key.

To discard the insertion and exit the insert mode of snippet parameters, press Esc.

To learn more about creating snippets and using placeholders, see How to manage SQL snippets.

The difference between SQL Complete snippets and SSMS templates/snippets

SQL Complete expands the built-in capabilities of SSMS template and snippet functionality and helps to make the usage of snippets more flexible.

The added value of SQL Complete includes but is not limited to a rich variety of replacement points (introduced via placeholders), customizable sharing options, easy creation, and reuse of custom snippets.