How to use code snippets
Last modified: June 2, 2025
Code snippets help you boost SQL code typing. You can use predefined snippets provided in the application and create own to insert them in SQL scripts and queries.
dbForge Studio code snippets are XML files with the .snippet file name extension.
The Code Snippets window contains a rich collection of templates organized in folders. In this window, you can arrange and preview snippets. In addition, you can use code snippets as a code repository using the Snippets Manager window.
View code snippets
To view a snippet, select it in the Code Snippets window. If the preview pane is not visible, right-click a snippet and select Toggle Preview from the menu.
Insert code snippets
1. Open the Code Snippets window by doing one of the following:
- On the View menu, select Code Snippets.
- Press Ctrl+K, Ctrl+X.
2. In the Code Snippets window that opens, choose the desired template and drag it to the SQL Editor.
3. Specify variable names and parameter values in the green lines and press Enter to complete code fragment editing.
Alternatively,
1. On the SQL Editor shortcut menu, select Insert Snippet.
2. Select the desired template.
3. Use Up Arrow and Down Arrow to select the item in the snippets list.
4. Specify variable names and parameter values in the green lines and press Enter to complete code fragment editing.
You can also insert code snippets by entering a template shortcut word or words and pressing Tab.
Note
If you want to include a code fragment into the inserted template, select it with the mouse pointer before placing a snippet in the editor. If the snippet does not provide surrounding, the selected text will be deleted.
To move a snippet to the root folder in the Code Snippets window, drag it onto an existing snippet in the root folder or move it to the upper border of the Code Snippets window.
Create code snippets
1. On the Tools menu, select Snippets Manager to open Snippets Manager.
2. On the Snippets Manager toolbar, select New Snippet.
3. In the Text field, enter the text of the snippet.
4. In the Shortcut and Description fields, specify a shortcut and snippet description, respectively.
Notes
The Location field is read-only and is automatically filled when you select a folder from the snippet list.
If a shortcut is assigned, it will be used as the snippet name. Otherwise, the snippet will be named Snippet by default. To rename a snippet, double-click it in the list and enter the desired name.
5. To save the changes, select Save on the toolbar.
Edit code snippets
1. On the Tools menu, select Snippets Manager. The Snippets Manager window opens.
2. Select the required snippet from the list of available snippets.
3. Modify the snippet description, shortcut, and text in the corresponding fields.
4. To save the changes, select Save on the toolbar.
5. To change the snippet name, double-click it in the list of available snippets.
Default snippets location
By default, all snippets are stored in a folder that is located at
C:\ProgramData\Devart\dbForge Studio for SQL Server\Snippets
.
You can change the default location when editing an existing snippet or creating a new one by setting a new path in the Location field of Snippets Manager.
Worked example: How to use code snippets as a code repository
Database developers often need to reuse scripts. dbForge Studio provides a solution for organizing and managing script storage efficiently. It allows you to structure scripts based on your needs, access them quickly, and modify the scripts and their storage hierarchy tree. You can achieve this using Snippets Manager.
Let us learn how to use Snippets Manager as a code repository.
Prerequisites
Before you begin, create an empty folder on your computer to store scripts. In our example, it is D:\ScriptRepository\MSSQL
.
Note
You can also specify a network folder if multiple users need to access and work with it.
Use Snippets Manager as a code repository
1. Open Snippets Manager by navigating to the Tools menu and selecting Snippets Manager.
2. At the bottom of Snippets Manager, select … in the Location box.
3. In the Select Folder window that opens, choose a folder you’ve created to store scripts - D:\ScriptRepository\MSSQL
- and select Select Folder.
The location folder is now changed to the selected folder - D:\ScriptRepository\MSSQL
.
4. On the Snippets Manager toolbar, select New Snippet to create a snippet.
5. Specify the following snippet details:
- Title – Enter a snippet name.
- Shortcut – Assign a shortcut that generates a script from the Text box.
- Description – Provide detailed information.
- Text – Enter the actual script.
6. On the Snippets Manager toolbar, select Save to save the snippet.
7. The created snippet appears under the folder in the left-side tree.
In the same way, you can create and save as many scripts as you need. As a result, you get a script repository, which you can quickly access while creating new scripts with predefined shortcuts.
The folder on your computer also displays the created code snippets.
To edit the created snippet:
1. In Snippets Manager, select the snippet in the left-side tree.
2. In the Text box, make the changes to the snippet.
3. To save the changes, select Save on the Snippets Manager toolbar.
To remove a snippet:
1. In Snippets Manager, select the snippet in the left-side tree.
2. On the Snippets Manager toolbar, select Delete to remove a snippet.
Want to find out more?
Overview
Take a quick tour to learn all about the key benefits delivered by dbForge Studio for SQL Server.
All features
Get acquainted with the rich features and capabilities of the tool in less than 5 minutes.
Request a demo
If you consider employing this tool for your business, request a demo to see it in action.