views:

1371

answers:

6

In my current project I've been inherited with lots of long (1200+ lines) SQL Server stored procedures with some horrible indentation and formatting which makes them almost unreadable. Is there some tool that I can use to automatically format these and make them more readable? I don't want to go through it manually and indent it.

+1  A: 

Check out Sql assist:

It has some format feature.

http://www.roundpolygons.com/Default.aspx?PageContentID=5&tabid=92

I would suggest downloading the evaluation version to see whether it fits your need.

J.W.
+4  A: 

Here's a couple -- no idea how well they work, unfortunately...

http://www.wangz.net/gsqlparser/sqlpp/sqlformat.htm (free)

http://www.sqlinform.com/ (free for personal use)

mwigdahl
SQLinform works very well, actually. Lots of options, you can lay out code the way you like best.
Tomalak
+3  A: 

Try redgate SQLPrompt. It has a 14-day trial.

Jamie Ide
+3  A: 

Red Gate "SQL Refactor" Very good. We bought it

Or

SSMS tools pack Free, but we don't use the layout features

gbn
A: 

Try www.softfrontiers.com/Downloads/ReIndenter.shtml Free (or donate) and download.

Works on C# and SQL Server code.

Is very fast and doesn't change the code except for indentation and endblock comments where missing and possible.

A: 

Try Ubitsoft's SQL Enlight (addin) or T-SQL Beautifier (online).

Ilian