SQL Server (T-SQL) Formatter

Format T-SQL for Microsoft SQL Server. Handles TOP, schema-qualified names and bracket identifiers. Paste your query and beautify it online.

Part of the free SQL Formatter. Runs in your browser — nothing is uploaded.

SQL Server (T-SQL) Formatter

T-SQL has its own habits: SELECT TOP, dbo-qualified names and [bracketed] identifiers. With the SQL Server dialect selected, your stored-procedure snippets and ad-hoc queries are laid out clearly for review.

Worked example: TOP and schema-qualified tables in T-SQL

Input

select top 10 e.EmployeeID, e.LastName, d.DepartmentName from dbo.Employees e inner join dbo.Departments d on d.DepartmentID = e.DepartmentID where e.HireDate >= '2020-01-01' order by e.HireDate desc;

Formatted T-SQL

SELECT
  TOP 10 e.EmployeeID,
  e.LastName,
  d.DepartmentName
FROM
  dbo.Employees e
  INNER JOIN dbo.Departments d ON d.DepartmentID = e.DepartmentID
WHERE
  e.HireDate >= '2020-01-01'
ORDER BY
  e.HireDate DESC;

Practical tip

Keep GO batch separators on their own line when pasting scripts from SSMS, then format each batch separately for the cleanest result.

How to use this SQL Formatter

  1. 1Use the live tool above — it runs entirely in your browser and never uploads your data.
  2. 2Paste the sample from the worked example, or use your own input.
  3. 3Copy the result, then adapt the same steps in your editor, script, or pipeline.

SQL Server (T-SQL) Formatter FAQs

Does it support SELECT TOP?

Yes. TOP n, schema-qualified names such as dbo.Employees and bracketed identifiers are handled with the SQL Server (T-SQL) dialect.

Can it format stored procedures?

It formats common statements inside procedures. Very procedural T-SQL with complex control flow may need manual touch-ups.

More SQL Formatter pages

Open the full SQL Formatter tool →