ErikEJ.DacFX.TSQLAnalyzer.Cli 1.0.26

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global ErikEJ.DacFX.TSQLAnalyzer.Cli --version 1.0.26
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local ErikEJ.DacFX.TSQLAnalyzer.Cli --version 1.0.26
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=ErikEJ.DacFX.TSQLAnalyzer.Cli&version=1.0.26
                    
nuke :add-package ErikEJ.DacFX.TSQLAnalyzer.Cli --version 1.0.26
                    

T-SQL Analyzer CLI

T-SQL Analyzer is a command line tool for identifying, and reporting the presence of anti-patterns in T-SQL scripts.

It evaluates more than 140 rules for design, naming and performance issues.

Getting started

The tool runs on any system with the .NET 8.0 runtime installed.

Installing the tool

dotnet tool install --global ErikEJ.DacFX.TSQLAnalyzer.Cli

Usage

# Analyze all .sql scripts in current folder and sub-folders
tsqlanalyze

## Analyze a single file
tsqlanalyze -i C:\scripts\sproc.sql

## Analyze a folder
tsqlanalyze -i "c:\database scripts"

## Analyze a folder with a filter and a full folder path
tsqlanalyze -i c:\database_scripts\sp_*.sql "c:\old scripts"

## Analyze a script with a rule settings filter and for a specific SQL Server version
tsqlanalyze -i C:\scripts\sproc.sql -r Rules:-SqlServer.Rules.SRD0004 -s SqlAzure

## Analyze a .dacpac and save results to an xml file
tsqlanalyze -i C:\scripts\Chinook.dacpac -o result.xml

## Analyze a .zip file with .sql files
tsqlanalyze -i C:\scripts\Fabric.zip

## Analyze a live database
tsqlanalyze -c "Data Source=.\SQLEXPRESS;Initial Catalog=Chinook;Integrated Security=True;Encrypt=false"

## Analyze a single file, and include path(s) to your own rules .dll file(s)
tsqlanalyze -i C:\scripts\sproc.sql -a C:\code\analyzers

## Analyze a single file, and reformat (PREVIEW)
tsqlanalyze -i C:\scripts\sproc.sql -f 

Rule settings filters are demonstrated here

The SQL Server version values are documented here

Sample output

The tool will output a summary of the rules that were violated, and the line numbers where the violations occurred.

Table3.sql:

CREATE TABLE [dbo].[Table3]
(
    [Id] INT NOT NULL, 
    [Wang] NCHAR(500) NOT NULL, 
    [Chung] NCHAR(10) NOT NULL 
)

Sample

GitHub Copilot MCP Server (PREVIEW)

You can use the tool to ask GitHub Copilot analyze your SQL Server CREATE scripts in Visual Studio or VS Code, just add the built-in MCP server to your Visual Studio or VS Code configuration.

Paste this link in you browser to prompt VS Code to install:

vscode:mcp/install?%7B%22name%22%3A%22tsqlanalyzer%22%2C%22command%22%3A%22tsqlanalyze%22%2C%22args%22%3A%5B%22-mcp%22%5D%7D

or install manually in one of the recommended locations:

{
    "servers": {
        "tsqlanalyzer": {
            "type": "stdio",
            "command": "tsqlanalyze",
            "args": [
                "-mcp"
            ]
        }
    }
}

SQL Formatting (PREVIEW)

Inspired by the SQL Formatter Visual Studio extension from Mads Kristensen, the -f switch will enable formatting of the analyzed scripts using the ScriptDom library.

  • Formats T-SQL code to a consistent and readable layout
  • Customizable formatting rules
  • .editorconfig support

See this for information about the .editorconfig format.

See this for information about the available options.

Enabling this will cause your script files to be updated!

SQL Server Management Studio (SSMS) and Visual Studio integration

You can run the tool against any script in the SQL editor, if configured as an external tool.

From the main menu, select Tools, External Tools and configure as shown:

SSMS

Title: tsqlanalyze

Command: C:\Users\<YourUserName>\.dotnet\tools\tsqlanalyze.exe

Arguments: -n -i $(ItemPath)

Use output window:

To run the tool, select Tools, tsqlanalyze and the result will be displayed in the Output window. Double click a warning to navigate to the related script line.

SSMS

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
1.0.31 12 7/30/2025
1.0.30 16 7/29/2025
1.0.29 360 6/17/2025
1.0.28 335 6/10/2025
1.0.27 274 6/9/2025
1.0.26 233 6/9/2025
1.0.25 247 5/27/2025
1.0.24 339 5/5/2025
1.0.23 171 4/30/2025
1.0.22 250 4/24/2025
1.0.21 313 4/16/2025
1.0.20 275 4/10/2025
1.0.19 235 4/9/2025
1.0.18 200 4/9/2025
1.0.17 256 4/7/2025
1.0.16 161 4/4/2025
1.0.15 361 3/23/2025
1.0.14 120 3/21/2025
1.0.13 166 3/19/2025
1.0.12 161 3/19/2025
1.0.11 154 3/19/2025
1.0.10 332 2/24/2025
1.0.9 159 2/24/2025
1.0.8 181 2/23/2025
1.0.7 283 2/19/2025
1.0.5 198 2/19/2025
1.0.0-preview.4 202 2/17/2025
0.9.174-nightly 139 2/16/2025
0.9.171-nightly 162 2/16/2025
0.9.169-nightly 165 2/16/2025
0.9.167-nightly 150 2/15/2025
0.9.166-nightly 137 2/15/2025
0.9.164-nightly 148 2/15/2025
0.9.156-nightly 132 2/15/2025
0.9.154-nightly 138 2/15/2025
0.9.152-nightly 151 2/15/2025
0.9.151-nightly 145 2/15/2025
0.9.150-nightly 140 2/15/2025
0.9.149-nightly 147 2/15/2025
0.9.141-nightly 146 2/14/2025
0.9.139-nightly 140 2/14/2025
0.9.137-nightly 115 2/12/2025
0.9.135-nightly 111 2/12/2025

Initial release