views:

559

answers:

5

I'm looking for a script or application that tidies up and reformats SQL queries. I've found some good online SQL formatters (see here) , as well as some downloadable commercial applications. I'm cautious about using an online service as I don't want to risk copies of these queries being stored somewhere they might be compromised, if only in a web server's cache (and it is against my employer's policy).

Does anyone know of any open-source applications, scripts, or downloadable freeware that might help me out with this?

It probably bears mentioning that I'm working on a Windows platform at work, but I am open to suggestions for other operating systems.

Cheers!

Update

I have used SQLInform as suggested by Vinko Vrsalovic to excellent effect. Thanks Vinko!

Something that might also be worth watching is SQLTidy, a young project on Google Code which could turn into something great in the long run.

A: 

Red Gate SQL Refactor (trial) + a Virtual Machine

Shawn Simon
A: 

I'd bet that there is an emacs mode and/or a vim extension for that.

+1  A: 

Some things to try out (sqlinform is free until 2009). It's weird how some niches totally lack good open source tools.

http://www.trialpay.com/checkout/?c=bb7014d&tid=6rGUpGo

http://www.sqlinform.com/license.phtml

http://www.fileheap.com/software-universal-sql-editor-download-11096.html

An Emacs macro:

http://www.emacswiki.org/emacs-en/tsql-indent.el

Vinko Vrsalovic
+1  A: 

Something else... this freeware tool works for PL/SQL, so maybe there's a use for that in there.

PL/SQL Tidy

Marcus Holt
A: 

T-SQL Beautifier - online free pretty printer.

Ilian