Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

Set up T-SQL checks in layers: lint the SQL files, build a SQL database project when your repository has a .sqlproj, and run database tests separately when you need to verify behavior. A linter checks style and selected patterns; a project build validates modeled syntax and references against its target platform; neither proves a change is safe against real data or performs as expected.

Choose checks for the shape of your repository

Start by identifying what CI will check: standalone scripts, a SQL database project, templated SQL, migrations, or a combination. Keep generated and vendor files out of linting unless your team intends to maintain them. A check only covers the files and project model it actually receives.

Repository content Useful check What it establishes
Standalone .sql files SQLFluff or TSQLLint Formatting and selected lint or anti-pattern rules. These tools do not require a database connection.
SQL database project (.sqlproj) Project build, optionally with Microsoft SQL code analysis Syntax and modeled object references against the configured target platform, plus configured analysis findings.
Procedures, functions, or changes whose behavior matters Database tests, such as tSQLt tests Behavior under the test database setup and data supplied by the tests.

These checks complement rather than replace one another. Microsoft documents project automation as a build with optional code analysis; tSQLt is a separate SQL Server unit-testing framework. See the SQL projects automation guidance and tSQLt overview.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Lint standalone T-SQL files

Choose and configure a linter

SQLFluff provides a T-SQL dialect and configurable lint and fix commands. Its dialect support is not a guarantee that every SQL Server syntax form is covered, so test it against representative files before making it a required merge gate. The stable documentation identifies itself as SQLFluff 4.3.0; releases can change, so check the release list and supported Python environment when selecting a version.

For ordinary, non-templated T-SQL files, commit a .sqlfluff file:

[sqlfluff]
dialect = tsql
templater = raw

raw is appropriate only when the SQL is not templated. SQLFluff supports other templaters, including Jinja, placeholders, Python, and dbt integration; configure the one that reflects how your source is produced. Consult the dialect reference and templating documentation.

Run the same pinned tool locally and in CI

One reproducible starting point is to pin the linter version in the project’s standard Python environment, then lint the relevant directory:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
python -m pip install sqlfluff==4.3.0
sqlfluff lint path/to/sql

Pinning avoids local and CI machines silently using different versions. The SQLFluff PyPI page provides published package information. Use sqlfluff fix deliberately during development, inspect its diff, and review changes in manageable batches; CI should normally run lint, not rewrite files. The CLI reference documents these separate commands.

A lint-only GitHub Actions workflow can run the same command on pull requests and pushes to the main branch:

name: T-SQL checks

on:
  pull_request:
  push:
    branches: [main]

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.x"
      - run: python -m pip install sqlfluff==4.3.0
      - run: sqlfluff lint path/to/sql

This is an example, not a claim that the action tags or tool version will remain current. Verify and pin action references under your organization’s dependency policy. Keep linter settings and dependency choices under version control. SQLFluff’s configuration reference describes configuration behavior.

Build and analyze a SQL database project

When the repository has a project model, build it in CI as a separate check. Set the project target platform to the intended deployment platform: the build’s syntax and feature validation depends on that setting. A successful build validates modeled references and syntax in scope; it does not validate every server-side behavior or guarantee deployment safety. See Microsoft’s target platform documentation and SQL projects overview.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Enable code analysis

For a Microsoft.Build.Sql SDK-style project, enable analysis in the .sqlproj:

Rank #3
Sale
<PropertyGroup>
  <RunSqlCodeAnalysis>True</RunSqlCodeAnalysis>
</PropertyGroup>

Then build the project:

dotnet build path/to/Database.sqlproj --configuration Release

A minimal GitHub Actions build step is:

- uses: actions/setup-dotnet@v4
  with:
    dotnet-version: "8.x"
- run: dotnet build path/to/Database.sqlproj --configuration Release

Check the repository’s project SDK and .NET SDK requirements rather than assuming this example fits older project formats. Pin SDK and action choices according to the team’s support policy. Microsoft’s automation documentation describes project builds and distinguishes them from deployment workflows. SqlPackage is for deployment or deployment-plan workflows; it is not needed just to lint files or build a project.

Make analysis findings actionable

Microsoft SQL code analysis includes rules concerning patterns such as SELECT *, @@IDENTITY, short variable-length types, deprecated join syntax, output parameters not assigned in every code path, and casts that may lose data. Performance rules may flag scans. These are prompts for review, not measured proof that a query is incorrect or slow in its real workload.

Analysis findings are warnings by default. Configure rule severity through SqlCodeAnalysisRules in the project file, and verify the resulting build behavior rather than assuming warnings block merges. Microsoft’s analysis setup guide shows how to configure rules and use StaticCodeAnalysis.SuppressMessages.xml for file-and-rule-specific suppressions. The SQL code analysis reference covers rule categories and severity.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Document why a rule is disabled or elevated. Keep suppressions narrow and review them when the affected code changes, so they do not silently become blanket exemptions.

Resolve system-object references

If a project reports unresolved references to system objects, check whether those objects are absent from its model. Microsoft documents adding a master.dacpac reference for the target platform. Follow the system objects guidance for the project configuration.

Handle templates, SQLCMD variables, and mixed repositories

Templated SQL

Configure the linter to use the same kind of templating as the source. A rendered template branch may not cover every conditional branch in the raw file, so test representative variants rather than treating one rendered result as complete coverage. SQLFluff describes templating options and this limitation in its templating documentation.

SQLCMD variables and placeholders

Provide safe representative values or use an appropriate templater. TSQLLint documents replacing placeholders from environment variables before applying lint rules. Do not put secrets in committed configuration or expose them through logs; see the TSQLLint README for its placeholder and configuration guidance.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Scripts outside the project

Run the linter and project build over their own intended scopes. A successful project build says nothing about migration scripts or other files that are not included in the project or another check.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Set merge-gate severity without overwhelming the team

For an established codebase, first run checks in reporting mode and review the existing findings. Agree on a baseline and documented exceptions, then gate a small set of high-confidence rules or require new code to meet the chosen standard. Keep subjective or context-dependent findings as warnings until the team understands their noise level.

TSQLLint lets rules be configured as off, warning, or error. An error-level violation returns a non-zero exit code; a warning does not. Its documented compatibility-level values are 80, 90, 100, 110, 120, 130, 140, and 150, with 120 as the default. Check the current project documentation for support and maintenance status before adopting it, especially if your environment needs a newer compatibility level.

Confirm that CI treats the check’s exit code as a failed job. A warning-only linter configuration or SQL project analysis defaults may report findings while still allowing a green build. Use autofixes in reviewed batches; large formatting diffs can hide functional changes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Add database tests for behavior

Static checks do not execute your SQL. When you need to verify procedure results or other behavior, add a separate test stage that provisions a SQL Server instance, installs the project and test framework, runs tests, and cleans up the environment. tSQLt supports T-SQL unit tests, faked tables, procedure spies, and plain-text or XML output for CI integration. Its overview and user guide describe the framework.

Tests can exercise behavior under their fixtures; they do not automatically establish that migrations are safe against production data or that query plans meet performance requirements. For those concerns, review deployment scripts and measure representative workloads in an appropriate environment.

Troubleshoot the check that failed

  • SQLFluff parse error: Inspect the dialect, templater configuration, and exact syntax. A parser failure is not proof that SQL Server rejects the file; confirm with a project build or suitable SQL Server environment. The dialect reference describes supported dialects.
  • Unresolved project reference: Check whether the object belongs to a referenced project or a system database model, and configure the reference required for the target platform.
  • Target-platform error: Confirm that the project target platform matches the intended deployment platform; the build evaluates syntax and features in that context.
  • Template-related gap: Verify that the linter is using the source’s templating approach and exercise relevant conditional variants.
  • Finding appears but the job stays green: Check whether the tool classified it as a warning and whether CI is observing the command’s exit status; explicitly choose which findings should fail the build.

Verify the pipeline before making it required

  1. Run the committed lint command locally against the same paths CI checks.
  2. Run the project build locally, if the repository includes a .sqlproj, with its configured target platform and analysis settings.
  3. Confirm a deliberate lint violation or configured error causes a non-zero command result and a failed CI job.
  4. Open a pull request and verify that it runs the same commands, configuration, and pinned tool versions.
  5. Keep database tests in a distinct stage so a green lint or build check is not mistaken for an execution test.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.