SQL Beautifier

I pulled a large amount of SQL out of some existing code and wanted to have it formated nicely for me. I figured there had to be some type of pretty printer for SQL available outside of applications like TOAD. I have access to TOAD but it would have required a reboot so I figured I would ask google what to do. There seem to be a number of different formaters out there. I found a couple people talking about current options a list here and here. The following list is a summary of the options I found:

I decided that since SQLInform was mentioned a lot I would give it a try. I was suprised at how well it did. I gave it a huge amount of SQL to re-format and it gave it back to me formated. There is a limit on how much you can ask it to format at once but that shouldn't be a big issue. I didn't see that it choked on anything that I gave it and there were all kinds of nasty things going on in the SQL.

One interesting thing to come from this is that it seems there are no open source or truely free unix based formaters out there. It seems like it would be easy enough to get going since the SQL grammar is available for a number of different parser generators.

Tags: , ,

4 thoughts on “SQL Beautifier

  1. GuidoMarcel

    thx for the nice review of the sqlinform site.
    With the next release I will increase the max size allowed for SQL statements. You will then be able to format monster SQL statements ;-)

  2. Pingback: Quellcode-Verschönerer und -Formatierer | Dr. Web Weblog

  3. Tao

    A little late maybe (only 6 years), but reasonably recently I implemented a free open-source T-SQL formatter similar to the commercial offerings you listed; It's not specifically designed for unix, but it does have a command-line version which can use StdIn/StdOut, so I guess its unixey-enough. It should also run in any environment that has Mono.

    Hope this helps someone: http://www.architectshack.com/PoorMansTSqlFormatter.ashx

Leave a Reply
