Home » sqlserverpedia-syndication »SSC »Tech and Learning » Currently Reading:

Great Tools for Formatting T-SQL

December 10, 2012 sqlserverpedia-syndication, SSC, Tech and Learning No Comments

For the month of December, I’ll be taking a little holiday from blogging. In the meantime, enjoy a few of my more popular golden oldies, like this one (original post here: http://wp.me/pZM1Z-FE). And be sure to drop by our live weekly webshow, DBAs@Midnight, at 11pm Central time on Fridays!

I have a big rant I add to….well, to every single SQL session I give. That rant is on formatting code. You see, (I say,) you can’t even begin to understand or optimize a query if it’s not formatted…and by “formattted”, I mean breaking out query clauses onto different lines, indenting column lists, etc etc.

Along with this speech, I normally give out a few resources for easier code formatting – after all, no one wants to go through every stored procedure, view, and trigger and format it by hand. In order of preference (most favorite down), here are those tools:

  1. Red-gate’s SQL Prompt – CTRL-K-Y formats all the code in your query window in a single go, as long as it’s parsable (no syntax errors). I cannot recommend this tool enough. It’s beautiful.
  2. Poor SQL Parser – This free online utility lets you copy-paste your code into and out of a window and format it. I haven’t yet downloaded the free version, but I’ll update you here when I do. Thanks to Brent Ozar for the link Friday (and thereby for the blog post inspiration)!
  3. SSMS ToolsPack – This won’t format the code (in its current version), but it changes all keywords to uppercase (e.g., select to SELECT). This is handier than you’d think.
  4. MS Word Macro – You can grow your own copy-and-paste-and-format utility with MS Word utilities, or you can use the SQL formatting macro code I supplied for you here.

Happy days,
Jen McCown
http://www.MidnightDBA.com/Jen

Share on TwitterShare on LinkedInShare on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit

Comment on this Article:

Blog Posts by Category

The Newsiest

Hear Sean and Jen on the PowerScripting Podcast! The MidnightDBAs were honored guests on episode 218. Check it out! Free SQL training, coming to a town near you A full day of SQL Server training is more than likely going to be at a town near you! Find out when and where at www.sqlsaturday.com/

The best database career advice you’ve never heard!

DBARoadmap.com

The DBA Roadmap Seminar is 7 MP3 tracks (over 5 hours!) of insider guidance on your database career. We'll teach you how and what to study as a DBA, weigh in on controversial resume debates, teach you to recognize a worthy recruiter, and discuss the new professionalism of interviews. Also some bonus materials, PDF companion guides, and really spiffy intro music!

Once your $99 PayPal payment is submitted, you'll get the download link in e-mail! (Download is a 370Mb ZIP file.)

Become a DBA. Become a BETTER DBA. Use the Roadmap.

Visit www.DBARoadmap.com for info, forums, and more!

Add to Cart View Cart

SQL Cruise rules!

We were on the January 2013 cruise to the Bahamas, teaching and learning SQL and having a GRAND time after hours...all for the less money than a week of "normal" SQL training. Check out the SQL Cruise site for info on the NEXT one!