Poor Man's T-SQL Formatter

Modified on 2019-08-04 11:51 by TaoK — Categorized as: C#, dotNet 2, IIS, SQL

Try it now on PoorSQL.com, the free
online TSQL formatting service
!

Overview

This is a free and open-source SQL (T-SQL) formatter:
This formatter does implement a high-level SQL tokenizer and parser, but the granularity of the parser is not very high. It does not distinguish between different types of DML, it does not parse full expression trees, etc - there's a lot it doesn't do, it just does the bare minimum to support the target formatting.

The library is largely complete, but undocumented. For the list of known issues, please see the issue tracker on github. As there is only as much parsing detail as necessary to support the desired formatting, the parse tree format is still not finalized; many formatting enhancements require new elements in the parse tree.

The code is hosted on GitHub at https://github.com/TaoK/PoorMansTSqlFormatter; I'm always very grateful for any feedback on the functionality, the code or any other aspect of the project!

To keep an eye on new releases or other related news, Follow @PoorSQL

Tweets by @PoorSQL

I also send out occasional announcement emails to people who've contacted me - email me at if you'd like to get these announcements (this might eventually become a real mailing list).



Download

Ready-to-run:









Compiled Library to use in other GPL/AGPL projects or internal non-distributed projects:
JS Library to use in other GPL/AGPL projects or internal non-distributed projects:
Source:

Latest Changes

1.6.16 - 2019-08-04

Changed


1.6.15 - 2019-08-01

Changed


1.6.14 - 2019-07-30

Changed


1.6.13 - 2019-07-27

Added


1.6.11 - 2017-11-24

Added


Changed


Full Change Log:
Known / Open Issues:

License / Redistribution

The library and accompanying programs are released under the Affero GPL. This means that you are allowed to make any changes you want, there are restrictions/requirements attached only if you choose to redistribute the original or modified code: If you choose to redistribute/expose the functionality, then you must make the source available to the recipients/users (even of a web service). For private usage, you can make any changes you want and never need to tell anyone; if you distribute the app/functionality or a service that relies on it, then you must also distribute the source. For more details, please see the AGPL article on wikipedia or at the source, the FSF (free software foundation).

At least for the moment (as I'm the only one who has contributed to the project so far), the project could be dual-licensed if you really, really wanted to use it in a commercial program. If so please contact me, I'm sure we could work something out.

Tips & Tricks


Feedback & Known Issues

For general feedback please email me at .

To browse existing / known issues or add new ones to be tracked, please use the GitHub issue tracker.

Instant Demo

The demo has been moved to poorsql.com - check it out and contact me with any issues!

Contributing

So far I many contributions, but contributing is easy with GitHub! Just fork the project, make your changes, and create a Pull Request for me to take a look and I will (if I agree with the changes of course) happily incorporate them!

https://github.com/TaoK/PoorMansTSqlFormatter

I need to formulate a "Contributor Agreement" to be able to accept any significant contributions, but that should be quick enough to do as the need arises, please let me know if you're interested.

Or if you just want to show your support, you can report your use of the project on Ohloh:

Background

Other Products and Projects

There is a comparison of all the SQL Formatting products that I know of, in wiki (editable) form, in the project wiki at https://github.com/TaoK/PoorMansTSqlFormatter/wiki/SQL-Formatter-comparisons.

(Previously there was a comparison table here, but it was years out of date and not editable by anyone but me. That was silly.)

Your Formatting preferences? Who are you?

The only reason my personal preferences are important here, is that I'm the one writing this :).

What I can do, however, is explain the rationale behind my preferences, in the hope that I might sway someone's opinion:

What if I want my SQL formatted differently?

I am completely open to providing additional formatting options, obviously within the time I have available to devote to this project. Existing open requests are tracked on the GitHub issue tracker, with prefix "Option: ". As the project is open source and hosted on github, it's also trivial to fork the project, download to your local machine and get cracking on any changes you'd like to see!