How to format SQL code in dbForge Studio for SQL Server
Last modified: June 23, 2025
dbForge Studio for SQL Server can help you to format your SQL statements, paying attention to case, line breaks, whitespaces, indenting, wrapping, etc. Statements with errors are skipped and are not formatted.
Configure formatting options
Before you format your code, you might want to configure formatting options and customize case formatting profiles. To tune formatting options:
- On the Tools menu, point to Options. The Options dialog box opens.
- On the Options dialog box, navigate to Text Editor, Formatting.
- Apply required changes. For more information, refer to the Formatting topic.
Format code
To format the whole code of a document, do one of the following:
- On the Text toolbar, click Format Document.
- Press Ctrl+K, D.
To format current statement, do one of the following:
- On the Text toolbar, click Format Current Statement.
- Click Format Current Statement on the SQL Editor shortcut menu.
- Press Ctrl+K, S.
To format a certain code fragment:
- Highlight a required code fragment.
- Click Format Selection on the SQL Editor shortcut menu. Alternatively, press Ctrl+K, F.
Formatting errors
The Studio can format only complete code blocks. Applying formatting to a code fragment, for example, a part of a query or a single line of code, will result in a syntax error.
Semicolon insertion
You can use dbForge Studio for SQL Server to insert missing semicolons after each statement in a query.
To insert semicolons, right-click the statement body and select Refactoring > Insert Semicolons. Alternatively, press Ctrl+K, ;.
Compare formatting profiles
You can use Devart Code Compare to compare XML-based formatting profile files and identify differences in structure, tags, and values.
Prerequisites
- Download and install Code Compare.
- Optional: Customize comparison settings for improved accuracy:
- Enable syntax highlighting for XML to improve readability.
- Select the Ignore insignificant whitespace option to filter out formatting-only differences. Format both XML files using a consistent formatting tool before comparison.
To compare formatting profiles
1. Open Code Compare.
2. Load the files you want to compare.
2.1. On the menu bar, select File > Open First File and choose the first file.
2.2. On the menu bar, select File > Open Second File and choose the second file.
Note
The default path to custom formatting profiles is
C:\Users\username\AppData\Roaming\Devart\dbForge Studio for SQL Server\FormatProfiles
.Replace
username
with your Windows user name.
Predefined profiles are not stored in this folder.
To compare a custom profile with a predefined profile
1. Open Tools > Options > Formatting > Profiles.
2. Create a new profile based on the settings of the required predefined formatting profile.
3. Save the new profile to that folder.
4. Use Code Compare to compare the saved profile file with your custom profile.
5. Review the comparison results. Differences are highlighted in both files.
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.