My main use is that it makes it easier to comment out stuff during development of queries. I lead with ,'s and and's:
SELECT
A
-- ,B
,C
,D
-- ,E
FROM TABLE
WHERE 1=1
-- and B='This'
and C='That'
-- and D is not null
Also makes it easier to programmatically tack stuff unto the end.
this = "SELECT * "
this += "FROM TABLE "
this += "WHERE 1=1 "
if user chooses option a then this += "and A is not null "
if user chooses option b then this += "and B is not null "
if user chooses option b then this += "and C is not null "
if user chooses option b then this += "and D is not null "
Otherwise you'd have to qualify the first option... and have each following option check the previous options. What if the user only chose Option D in the previous example? You'd have to make sure that if A, B and C aren't chosen then use WHERE else use and. With = at the start, you can just slap the qualifiers to the end of the statement.
codesimilar to the first block in SSMS or similar query tools. Researching data sets and getting the right results before it gets put into reporting tools (like Crystal Reports) for end users. The second block is what I've seen other people do, since my job hasn't been too much about raw sql access. I've troubleshot other peoples similar code and can understand the reasoning. (Code was in VB, C# and PHP). – WernerCD Dec 15 '13 at 18:25