SQL Formatter

SQL Formatter

Recently I come across a beautifull tool SQL Fromatter Tool SQL Pertty Printer. A wonderful tool for us who are just living on SQL. As we all know properly formatted SQL can be better readable and understandable than unformatted query.
But for me it just a tidy process to format query with proper use of UpperCase and LowerCase for keywords. Here SQL Pretty printer comes. It formats your query as you want.



First I will put a sample so you can get idea how powerfull this tool is.


Unformatted code

select OBJECT_SCHEMA_NAME(object_id) as Schema_Name, case when grouping (OBJECT_NAME(object_id)) = 1 then 'Total of tables' else OBJECT_NAME(object_id) end table_name, COUNT(*)
from sys.columns
WHERE OBJECTPROPERTY(object_id, 'IsUserTable') = 1
GROUP BY OBJECT_SCHEMA_NAME(object_id), OBJECT_NAME(object_id)
WITH ROLLUP
having GROUPING(OBJECT_SCHEMA_NAME(object_id))<> 1
order by GROUPING (OBJECT_NAME(object_id)), COUNT(*)

Formatted Code


SELECT Object_schema_name(object_id) AS schema_name,

CASE

WHEN Grouping(Object_name(object_id)) = 1 THEN 'Total of tables'

ELSE Object_name(object_id)

END table_name,

Count(* )

FROM sys.columns

WHERE Objectproperty(object_id,'IsUserTable') = 1

GROUP BY Object_schema_name(object_id),

Object_name(object_id) WITH ROLLUP

HAVING Grouping(Object_schema_name(object_id)) <> 1

ORDER BY Grouping(Object_name(object_id)),

Count(* )


You can see how cool it is.

Now some cool feature of this tool



Like uppercase or lowercase or initcap for keywords,identifier and functions.
Lots of options like linebreaks, taboptions and alignments etc..


SQL Pretty Pritner is available web based also.

You can try it here

http://www.dpriver.com/pp/sqlformat.htm

I have installed it in my Management studio and I am enjoying it. Just write a query and format it using SQL Formatter.

No comments:

Post a Comment

Popular Posts