by Joe Havelick
7. January 2008 22:06
The importance of well formatted code can be appreciated by any seasoned professional. This is transient across any language I've dealt with, including SQL. Visual Studio has functionality for auto-formatting your XHTML, C#, and VB.NET code (CTRL+K, CTRL+D), but SQL Management Studio, a derivative of Visual Studio, doesn't have such a luxury for SQL/TSQL code.
Instant SQL Formatter does have a functional online formatter for neatening up your SQL script for free. Additionally, for a price, you can download an add-in to Visual Studio, or SQL Management Studio for embedded functionality.
A number of parameters allow you to customize the result, ranging from the desired database type, to language. This will allow you to take ugly scripts like this:
select column1, column2, column3
from table1 inner join table2 on table1.cloumn2 = table2.column2
where value = 'false'
and turn them to this:
SELECT COLUMN1,
COLUMN2,
COLUMN3
FROM TABLE1
INNER JOIN TABLE2
ON TABLE1.CLOUMN2 = TABLE2.COLUMN2
WHERE VALUE = 'false'
Perhaps not an astounding example, but when applied to large, chaotically formatted scripts, it can make a huge difference.
35b611ba-848e-480b-a4ad-4f4fbed9f1ec|1|4.0|27604f05-86ad-47ef-9e05-950bb762570c
Tags: sql
Tech Tips