ErikEJ.DacFX.TSQLAnalyzer.Cli 1.0.38

Prefix Reserved
{
  "servers": {
    "ErikEJ.DacFX.TSQLAnalyzer.Cli": {
      "type": "stdio",
      "command": "dnx",
      "args": ["ErikEJ.DacFX.TSQLAnalyzer.Cli@1.0.38", "--yes", "--", "-mcp"]
    }
  }
}
                    
This package contains an MCP Server. The server can be used in VS Code by copying the generated JSON to your VS Code workspace's .vscode/mcp.json settings file.
dotnet tool install --global ErikEJ.DacFX.TSQLAnalyzer.Cli --version 1.0.38
                    
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.38
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=ErikEJ.DacFX.TSQLAnalyzer.Cli&version=1.0.38
                    
nuke :add-package ErikEJ.DacFX.TSQLAnalyzer.Cli --version 1.0.38
                    

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 .dacpac and save results to a JSON file
tsqlanalyze -i C:\scripts\Chinook.dacpac -o result.json

## 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

Note: UTF-8 with BOM encoding is required for the input files.

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

MCP Server (preview)

You can use the tool to ask GitHub Copilot analyze your SQL Server CREATE scripts in Visual Studio or VS Code.

The TSQL Analyzer MCP Server supports quick installation across multiple development environments. Choose your preferred client below for streamlined setup:

Client One-click Installation MCP Guide
VS Code Install in VS Code VS Code MCP Official Guide
Visual Studio Install in Visual Studio Visual Studio MCP Official Guide

Example JSON configuration:

{
    "servers": {
        "tsqlanalyzer": {
            "type": "stdio",
            "command": "dnx",
            "args": [
                "ErikEJ.DacFX.TSQLAnalyzer.Cli",
                "--yes",
                "--",
                "-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) 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 is compatible.  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.38 54 2/13/2026
1.0.37 43 2/13/2026
1.0.36 245 1/4/2026
1.0.35 523 11/10/2025
1.0.34 651 9/3/2025
1.0.33 288 8/22/2025
1.0.32 371 8/6/2025
1.0.31 1,165 7/30/2025
1.0.30 163 7/29/2025
1.0.29 471 6/17/2025
1.0.28 419 6/10/2025
1.0.27 348 6/9/2025
1.0.26 311 6/9/2025
1.0.25 307 5/27/2025
1.0.24 399 5/5/2025
1.0.23 257 4/30/2025
1.0.22 320 4/24/2025
1.0.21 401 4/16/2025
1.0.20 356 4/10/2025
1.0.19 294 4/9/2025
Loading failed

Initial release