SQL Formatter Tool


By:   |   Updated: 2006-06-07   |   Comments (6)   |   Related: More > 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.

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


Last Updated: 2006-06-07


get scripts

next tip button



About the author
MSSQLTips author Greg Robidoux Greg Robidoux is the President of Edgewood Solutions and a co-founder of MSSQLTips.com.

View all my tips
Related Resources





Comments For This Article




Friday, October 11, 2013 - 12:49:49 AM - Aravind Back To Top (27113)

This is one of the Online SQL Code Formatter that I use regularly,

http://sqlserverlearner.com/online-tools/tsql-code-formatter

 


Tuesday, May 21, 2013 - 5:57:29 AM - Marina Nastenko Back To Top (24063)

There is also a free on-line SQL-formatter from Devart http://www.sql-format.com/ which is powered by a more profound add-in for SSMS and VS - SQL Complete. It works just for SQL Server but it's a good one with lots of formatting options.


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)


Tuesday, April 17, 2012 - 5:57:06 AM - ameyoko Back To Top (16960)
Free SQL Formatter MAIDEN JAPAN

http://sqlconvert.x10.mx/rgyxd36680/SilverlightSQLConvert.html


SQLConvert for Silverlight

Monday, April 02, 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



download


Recommended Reading

Connecting to SQL Server Using SQLCMD Utility

Different Ways to Connect to SQL Server Using sqlcmd

Quest Foglight for Databases

Installing and Using mssql-cli on Linux for SQL Server

SQL Server Documentation Tools





get free sql tips
agree to terms


Learn more about SQL Server tools