Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Query guideline formatting

Author  Topic 

dnf999
Constraint Violating Yak Guru

253 Posts

Posted - 2007-05-10 : 12:31:15
Hi

I was just wondering what is the standard formatting when it comes to writing queries. Can anybody point me to a website.

i.e. how best would it be to format the below query (spaces and tabs etc)


select * from Suppliers
where MATCHKEY_Address1_Postcode in
(select MATCHKEY_Address1_Postcode
from Suppliers
where len(MATCHKEY_Address1_Postcode) > 0
group by MATCHKEY_Address1_Postcode
having count(*) > 1)
order by MATCHKEY_Address1_Postcode


Thanks!

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-05-10 : 12:34:57
everyone has their own way of writing it. Sometimes people are picky and want all keywords in caps etc. In one of my previous jobs, a guy got fired for improper formatting in SQL code.

Dinakar Nethi
SQL Server MVP
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

dnf999
Constraint Violating Yak Guru

253 Posts

Posted - 2007-05-10 : 12:41:14
lol that is harsh!!
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-05-10 : 12:53:49
Yes, you cannot afford to be picky when you are beginning to learn but once you become the boss you can so.. check out the SQLRefactor tool from red-gate software. I used their trial version and have liked "most" of their formatting. At least you can have something to start with.

Dinakar Nethi
SQL Server MVP
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page
   

- Advertisement -