How to work with T-SQL Code Analyzer

Enable T-SQL Code Analyzer

To enable the T-SQL Code Analyzer, in the SQL document, enter the code you want to validate. Right-click the SQL document body and select Analyze Code.

Enable T-SQL Code Analyzer

Note

T-SQL Code Analyzer validates code only in the active SQL document and only after you select Analyze Code. It does not automatically analyze code as you write.

Inspect issues

To analyze the code in your SQL document against the code analysis rules of your active profile, right-click the body of the SQL document and select Analyze Code. Once dbForge Studio finishes the analysis, non-compliant code is underlined with a green wavy line. Hover over the underlined code fragment to view the issue details. Additionally, the results of the code analysis are displayed in both the Error List and Output windows.

Enable T-SQL Code Analyzer

T-SQL Code Analyzer output

Code analysis output in the Error List

When the T-SQL Analyzer identifies code that violates the rules, it displays one of the following message types in the Studio List: T-SQL Code Analyzer Warning Warning, T-SQL Code Analyzer Error, Error, and T-SQL Code Analyzer Hint Hint.

The Error List presents the T-SQL Code Analyzer output in a table format. The Code column displays the rule identifier, clicking which will open a detailed description of the rule in the product documentation. The Description column contains the rule title. The File column shows the document name where the analysis is being conducted, and the Line column shows the line number where the rule was triggered. For additional details about the rule, click the Expand icon at the beginning of the row.

Code analysis output in the SQL document

When a rule is triggered in a SQL document, the corresponding code is underlined with a wavy line. Hovering over this code displays a hint with the rule details.

T-SQL Code Analyzer output

Code analysis info in the Output window

Information regarding the results of code analysis is also displayed in the Output window.

T-SQL Code Analyzer output

Enable and disable code analysis rules

You can customize T-SQL Code Analyzer by disabling rules that you do not find useful to reduce the number of issues in your script.

To view the list of all rules and enable or disable them individually, navigate Tools > Options > Code Analysis > Profiles. Then select the active profile and click Open Selected. In the dialog that opens, you can select the code analysis rules you want to apply to your code. By default, all the rules are selected. If you want to exclude the rule from the profile settings, clear the corresponding checkbox.

Open T-SQL Code Analyzer options

dbForge Studio for SQL Server allows the user to create multiple custom code analysis profiles. For more details, refer to Customize T-SQL Code Analyzer.

Want to Find out More?

Overview

Overview

Take a quick tour to learn all about the key benefits delivered by dbForge Studio for SQL Server.
All Features

All features

Get acquainted with the rich features and capabilities of the Studio in less than 5 minutes.
Request a demo

Request a demo

If you consider employing the Studio for your business, request a demo to see it in action.
Ready to start using dbForge Studio for SQL Server?