ErikEJ.DacFX.TSQLAnalyzer.Cli 1.0.34

Prefix Reserved
{
  "inputs": [],
  "servers": {
    "ErikEJ.DacFX.TSQLAnalyzer.Cli": {
      "type": "stdio",
      "command": "dnx",
      "args": ["ErikEJ.DacFX.TSQLAnalyzer.Cli@1.0.34", "--yes", "--", "-mcp"],
      "env": {}
    }
  }
}
                    
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.34
                    
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.34
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=ErikEJ.DacFX.TSQLAnalyzer.Cli&version=1.0.34
                    
nuke :add-package ErikEJ.DacFX.TSQLAnalyzer.Cli --version 1.0.34
                    

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 Manual configuration required Visual Studio MCP Official Guide

Example JSON configuration:

{
    "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) 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

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
1.0.34 373 9/3/2025
1.0.33 214 8/22/2025
1.0.32 325 8/6/2025
1.0.31 214 7/30/2025
1.0.30 103 7/29/2025
1.0.29 405 6/17/2025
1.0.28 354 6/10/2025
1.0.27 288 6/9/2025
1.0.26 252 6/9/2025
1.0.25 255 5/27/2025
1.0.24 348 5/5/2025
1.0.23 185 4/30/2025
1.0.22 258 4/24/2025
1.0.21 328 4/16/2025
1.0.20 294 4/10/2025
1.0.19 243 4/9/2025
1.0.18 216 4/9/2025
1.0.17 263 4/7/2025
1.0.16 176 4/4/2025
1.0.15 370 3/23/2025
1.0.14 137 3/21/2025
1.0.13 173 3/19/2025
1.0.12 168 3/19/2025
1.0.11 163 3/19/2025
1.0.10 339 2/24/2025
1.0.9 165 2/24/2025
1.0.8 189 2/23/2025
1.0.7 289 2/19/2025
1.0.5 211 2/19/2025
1.0.0-preview.4 209 2/17/2025
0.9.174-nightly 155 2/16/2025
0.9.171-nightly 177 2/16/2025
0.9.169-nightly 172 2/16/2025
0.9.167-nightly 163 2/15/2025
0.9.166-nightly 149 2/15/2025
0.9.164-nightly 155 2/15/2025
0.9.156-nightly 141 2/15/2025
0.9.154-nightly 145 2/15/2025
0.9.152-nightly 157 2/15/2025
0.9.151-nightly 153 2/15/2025
0.9.150-nightly 157 2/15/2025
0.9.149-nightly 153 2/15/2025
0.9.141-nightly 153 2/14/2025
0.9.139-nightly 151 2/14/2025
0.9.137-nightly 123 2/12/2025
0.9.135-nightly 117 2/12/2025

Initial release