Skip to main content
net10.0net8.0

A library for ad-hoc analysis of SQL scripts - see https://github.com/ErikEJ/SqlServer.Rules/blob/master/docs/readme.md

Published
Sep 7, 2026
1mo ago
Total Downloads
12.7K
12,651

Install

dotnet add package ErikEJ.DacFX.TSQLAnalyzer --version 1.0.70
ProductVersions
.NET
net10.0net8.0

README

NuGet

ErikEJ.DacFX.TSQLAnalyzer

This .NET 8 library allows you to run 140+ static T-SQL code analysis rules against .sql files, and report any rule violations.

Installation

Install the latest package from NuGet.

Getting started

Once installed, you can use the library to analyze T-SQL files. The library comes with a couple of useful extension methods to help you format the output of the analysis.

using ErikEJ.DacFX.TSQLAnalyzer;
using ErikEJ.DacFX.TSQLAnalyzer.Extensions;

var files = new List<string> { "C:\\scripts\\sproc.sql" };

var analyzerOptions = new AnalyzerOptions();

analyzerOptions.Scripts.AddRange(files);

var analyzerFactory = new AnalyzerFactory(analyzerOptions);

AnalyzerResult result;

try
{
    result = analyzerFactory.Analyze();
}
catch (ArgumentException aex)
{
    Console.WriteLine(aex.Message);
    return 1;
}

if (result?.Result == null)
{
    Console.WriteLine("No result from analysis");
    return 1;
}

foreach (var err in result.Result.InitializationErrors)
{
    Console.WriteLine(err.Message);
}

foreach (var err in result.Result.SuppressionErrors)
{
    Console.WriteLine(err.Message);
}

foreach (var err in result.Result.AnalysisErrors)
{
    Console.WriteLine(err.Message);
}

if (result.ModelErrors.Count > 0)
{
    foreach (var dex in result.ModelErrors)
    {
        Console.WriteLine(dex.Value.Format(dex.Key));
    }
}

if (result.Result.AnalysisSucceeded)
{
    foreach (var err in result.Result.Problems)
    {
        var warning = err.GetOutputMessage(analyzerOptions.Rules);

        Console.WriteLine(warning);
    }
}

Changes from Previous Version

No structural changes between v1.0.69 and v1.0.70.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

Compatibility metadata lists 2 target frameworks; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.