Can you recommend a sql formatter?

Chris Sijtsma 106 Reputation points
2020-11-17T14:17:45.18+00:00

Dear colleagues,

Which SQL formatter would you recommend? In our organization, we have coding standards. My problem is, there are to many of them. As I am responsible for the repositories containing SQL, I want to enforce a single standard by automatically formatting the code in check-in. I would like to have some configuration options to tweak the format to my liking.

Thanks for your help,
Chris

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,784 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,555 questions
{count} votes

Accepted answer
  1. Dirk Hondong 871 Reputation points
    2020-11-17T14:39:24.05+00:00

    If you just want to do it quickly, why not utilize the RedGate Page?
    https://www.red-gate.com/website/sql-formatter

    Otherwise they have the formatter in their tool SQLPrompt as well, but it is not for free.
    Other way to do it:
    Visual Studio Code
    Afaik there's also the option to format code.

    But since you want to establish a standard ( I Really should start reading first all information before answering... :-) )
    it is easier to go for an appropriate tool.

    ApexSQL is another one where you can also define how T-SQL code should look like.

    Regards
    Dirk

    1 person found this answer helpful.
    0 comments No comments

7 additional answers

Sort by: Most helpful
  1. Tom Phillips 17,716 Reputation points
    2020-11-17T15:58:07.203+00:00

    FYI, ApexSQL has started charging for the Refactor tool which reformatted SQL (was free until recently).

    1 person found this answer helpful.
    0 comments No comments

  2. m 4,271 Reputation points
    2020-11-18T02:14:43.4+00:00

    Hi @Chris Sijtsma ,

    Which SQL formatter would you recommend?

    Aggree with @Dirk Hondong and @Tom Phillips .

    ApexSQL Refactor

    Actually, there are many online sql fomatter tools, you can input "sql server formatter" in google and have a reference.
    And this article will guide you through some SQL formatter options via SSMS and using 3rd party SQL formatting tool such is ApexSQL Refactor to format code.

    More information:how-to-format-sql-code-in-sql-server-management-studio

    BR,
    Mia

    1 person found this answer helpful.
    0 comments No comments

  3. SQLZealots 276 Reputation points
    2020-11-18T03:04:40.727+00:00

    You may refer the below link for few more options.

    sql-formatters-beautify-your-code-and-coding-experience

    Please mark this reply as answer if it solved your issue or vote as helpful if it helped.
    Blog
    LinkedIn

    1 person found this answer helpful.
    0 comments No comments

  4. m 4,271 Reputation points
    2020-11-18T02:15:36.603+00:00

    Hi @Chris Sijtsma ,

    Which SQL formatter would you recommend?

    Aggree with @Dirk Hondong and @Tom Phillips .

    ApexSQL Refactor

    Actually, there are many online sql fomatter tools, you can input "sql server formatter" in google and have a reference.
    And this article will guide you through some SQL formatter options via SSMS and using 3rd party SQL formatting tool such is ApexSQL Refactor to format code.

    More information:how-to-format-sql-code-in-sql-server-management-studio

    BR,
    Mia


    If the answer is helpful, please click "Accept Answer" and upvote it.