[ssmsmarketplace]: [repo]: # T-SQL Analyzer ## Live Code Analysis for SQL scripts in SQL Server Management Studio 22 [![Build](https://github.com/ErikEJ/SqlServer.Rules/actions/workflows/vsix.yml/badge.svg)](https://github.com/ErikEJ/SqlServer.Rules/actions/workflows/vsix.yml) ![GitHub Sponsors](https://img.shields.io/github/sponsors/ErikEJ) Download the latest build of this extension from the [SSMS VSIX Gallery][ssmsmarketplace] ---------------------------------------- Analyze your SQL scripts as you type, and get suggestions for improvements based on best practices. The analyzer has over [140 rules](https://github.com/ErikEJ/SqlServer.Rules/blob/master/docs/readme.md) covering performance, security, maintainability, and more. The extension works with both SQL Server and Azure SQL Database projects based on [MSBuild.Sdk.SqlProj](https://github.com/rr-wfm/MSBuild.Sdk.SqlProj) or [Microsoft.Build.Sql](https://github.com/microsoft/DacFx/tree/main/src/Microsoft.Build.Sql) as well as classic [SQL database projects](https://learn.microsoft.com/sql/tools/sql-database-projects/get-started?view=sql-server-ver17&pivots=sq1-visual-studio). The extension will respect any rule configuration you have in your SQL project, including whether analysis is enabled, SQL version and rule suppression. ```xml net10.0 Sql170 True -SqlServer.Rules.SRD0006 -SqlServer.Rules.SRD0006;-Microsoft.* ``` In addition, the extension supports analysis of any SQL script in your editor, whether it is part of a project or not. You can customize the behavior of the extension via Tools/Options. ### Customizing Rules All rules are enabled by default. You can fine-tune them in Tools/Options using a simple expression: | What you want | Expression | | --- | --- | | Disable a single rule | `-SqlServer.Rules.SRD0004` | | Disable all naming rules | `-SqlServer.Rules.SRN*` | | Promote a rule to an error | `+!SqlServer.Rules.SRN0005` | | Combine several | `-SqlServer.Rules.SRD0004;+!SqlServer.Rules.SRN0005` | You can set this expression in the `Rules expression` option under Tools/Options when a SQL project rule configuration is not available. | Promote a rule to an error | `+!SqlServer.Rules.SRN0001` | | Combine several | `-SqlServer.Rules.SRD0004;+!SqlServer.Rules.SRN0001` | - The extension automatically uses the `dnx` command to run the T-SQL Analyzer CLI tool as a NuGet package. No separate installation is required. - The [.NET 10 SDK](https://dotnet.microsoft.com/en-us/download) is required and is automatically installed with the Database DevOps workload in SSMS. ### Analysis Errors If a script cannot be fully modeled or an analysis rule fails, the available findings are still shown in the Error List. Details of these errors (kind, code, and message) are logged to the **Output** window. Findings may be incomplete until these errors are resolved. ## How can I help? Should you encounter bugs or have feature requests, head over to the [GitHub repo][repo] to open an issue if one doesn't already exist. Another way to help out is to [sponsor me on GitHub](https://github.com/sponsors/ErikEJ). If you would like to contribute code, please fork the [GitHub repo][repo] and submit a pull request.