sqlformattingreadability

Why should I capitalize my SQL keywords? Is there a good reason?


Possible Duplicate:
Is there a good reason to use upper case for T-SQL keywords?

I personally find a string of lowercase characters to be more readable than a string of uppercase characters. Is some old/popular flavor of SQL case-sensitive or something?

For reference:

select
    this.Column1,
    case when this.Column2 is null then 0 else this.Column2 end
from dbo.SomeTable this
    inner join dbo.AnotherTable another on this.id = another.id
where
    this.Price > 100

vs.

SELECT
    this.Column1,
    CASE WHEN this.Column2 IS NULL THEN 0 ELSE this.Column2 END
FROM dbo.SomeTable this
    INNER JOIN dbo.AnotherTable another ON this.id = another.id
WHERE
    this.Price > 100

The former just seems so much more readable to me, but I see the latter way more often.


Solution

  • I think the latter is more readable. You can easily separate the keywords from table and column names, etc.