SQL Formatter Tool

By:   |   Comments (3)   |   Related: > Tools


Problem

One of the things that drives me crazy is having to format my SQL statements. It is hard enough writing the statements in the first place, but then having to take the time to format the code, make keywords uppercase, using tabs to align column names, tables names etc... is just a lot of work. But it is one of those things that if you don't do it now it never happens except for the next time that you edit that code and spend a bunch of time formatting it anyway.

Solution

Well one option is to do the formatting as you write your SQL code. This makes the most sense, but often times you get code from other places or when you copy and paste the code everything is misaligned.

Here is a free online formatter tool that allows you to just paste in your SQL statements and it will format the statement automatically based on some of the options you select. Overall it is an extremely simple process, but a tool that you will use over and over again.

Here is the URL.  Also check out other options in the comments below.
http://www.dpriver.com/pp/sqlformat.htm?ref=g_wangz

Below is a simple screen reproduction of what the tool looks like.

creenshot

Next Steps
  • Don't waste time formatting your code go check out this tool to see how helpful it really is
  • Whenever you write SQL code use this simple tool to reformat the code for you
  • Bookmark the above URL and add it to your toolbox


sql server categories

sql server webinars

subscribe to mssqltips

sql server tutorials

sql server white papers

next tip



About the author
MSSQLTips author Greg Robidoux Greg Robidoux is the President and founder of Edgewood Solutions, a technology services company delivering services and solutions for Microsoft SQL Server. He is also one of the co-founders of MSSQLTips.com. Greg has been working with SQL Server since 1999, has authored numerous database-related articles, and delivered several presentations related to SQL Server. Before SQL Server, he worked on many data platforms such as DB2, Oracle, Sybase, and Informix.

This author pledges the content of this article is based on professional experience and not AI generated.

View all my tips



Comments For This Article




Tuesday, July 24, 2012 - 8:29:34 AM - Andrei Back To Top (18772)

These free add-ins also do the job:

http://www.ssmsboost.com/  (has also more additional features)

http://www.architectshack.com/PoorMansTSqlFormatter.ashx  (available as add-in and as online tool)


Monday, April 2, 2012 - 9:37:09 AM - bertha Back To Top (16737)

and another at www.sql2string.com

it's very simple, free and useful.


Monday, February 27, 2012 - 5:50:59 PM - Guido Back To Top (16178)

There is another free online SQL Formatter at www.sqlinform.com















get free sql tips
agree to terms