views:

3053

answers:

9

I was wondering if there is a plugin/tool for SQL Server Management Studio that will format your SQL?

I'm working with some large-ish stored procs that are a mangled mess of poorly formatted SQL and it'd be nice if I could just go "Select All -> Format SQL"

+6  A: 

Red-Gate makes a couple, either Sql Prompt Pro or Sql Refactor. There are a million others out there that do not plug into management studio, but Red-Gate makes the only plugin I know of and it works very well. They also provide intelli-sense and a few other useful features.

http://www.red-gate.com/products/SQL_Prompt/index.htm

ShaneD
SLQ Refactor is pretty nice, altho $295 is probably a little out of my price range for this particular project. I'll definately keep it in mind for next time tho
lomaxx
The Red Gate SQL Refactor/Prompt. Is quite nice and has handled all my wishes this far.
bjorsig
Anyone who uses SQL regularly will save lots of time with this.
Jason Lepack
+1  A: 

This one (Gudu Software) is pretty good, works in Management Studio and is pretty cheap. It needs more options in my opinion but haven't used it for a few months, maybe they've added some new features. I was happy with it when I used it. Also has a free online version.

jcollum
this one is more in my immediate price range... thanks
lomaxx
+7  A: 

This is a free, online one: http://www.sqlinform.com/ (requires Java Runtime Environment)

Mitch Wheat
This is a good one, based on a few simple queries.
Jason Lepack
They also have a downloadable executable.
GluedHands
The downloadable version is only $30, so much cheaper than RedGate
Michael La Voie
Actually $50 now. Just tried it, and it works well and is customizable.
littlegreen
+1  A: 

Today I discovered Apex SQL Refactor. It is a free plugin. Integrates with SSMS. Downside is that it is an all or nothing process. It does not refactor as you type.

Mauricio Mendoza
Things may have changed. Apex SQL Refactor is $200.
Nick VanderPyle
A: 

Not a plugin for SSMS, but I find this handy to keep as a bookmark in my browser: http://www.dpriver.com/pp/sqlformat.htm

Edit: Oops - I just noticed they have versions for SSMS, Visual Studio, and a desktop version etc. Haven't tried them personally yet.

Phil Haselden
A: 

Check SQL Enlight.

Ilian
+2  A: 

SSMS Tools Pak does a good job of formatting and the other tools in the pack come in quite handy

MG48
As far as I can tell it just makes all keywords upper or lower case, pretty rudimentary.
Nathan Baulch
A: 

Or you could try my formatter.It is not free. it is a command line tool and it can integrated with SSMS as an external tool.... Tidycode T-Sql Formatter

Aftershock
A: 

This web site here does basic SQL keyword capitalisation:

http://www.ascdesc.com

BombDefused