2023-06-06

TSQL Anti-Pattern Scanning Free Tool - TSQLLint

This month blog post I would like to share a free tool for scanning anti-pattern in T-SQL code, the TSQLLint which can also be integrated into SSMS. Below steps show how to install and use it. You only needed to install it in your machine, unnecessarily in the SQL Server.

1. Download and install the latest .NET for Windows (.NET 6.0 or higher). 

2. Open a Command Prompt, run below command:
    dotnet tool install --global TSQLLint

3. Find the location where the tsqllint.exe installed, it should in the Path environment variable.
    E.g. %USERPROFILE%\.dotnet\tools

4. Open SSMS -> Tools -> External Tools...

5. Enter the following:
    - Command: full path including EXE name
    - Arguments: $(ItemPath)
    - Initial Directory: put the folder path without exe name
    - Check Use Output window
    - Title: tsql-lint

6. Now you can try to use it. Open the sql script file you want to check in SSMS, then run the tsql-lint external tool. You will see the scanning result in the output window. Double-click a result row it will bring you to the corresponding line of code.

Let's share this tool to T-SQL developers!