On “Bad Habits to Kick : Using AS instead of = for column aliases” (via: Aaron Bertrand)
Posted by jpluimers on 2014/01/22
A while ago, I came across an interesting post Bad Habits to Kick : Using AS instead of = for column aliases by Aaron Bertrand, a major contributor on SQLblog.com – The SQL Server blog spot on the web.
The last link indicates my problem with this “AS” versus “=”: it is SQL Server specific.
So, if you mainly use SQL Server, then it is OK (or even preferable) to use “=” for aliasing columns in human written SQL as it makes spotting the names used much easier.
= alias
[sourcecode language=”sql”]
select
tableName = o.name,
columnName = c.name,
columnTypeName = t.name
from sysobjects as o
inner join syscolumns as c on c.id = o.id
inner join systypes as t on t.usertype = c.usertype
where o.type = ‘S’
[/sourcecode]
as alias
[sourcecode language=”sql”]
select
o.name as tableName,
c.name as columnName,
t.name as columnTypeName
from sysobjects as o
inner join syscolumns as c on c.id = o.id
inner join systypes as t on t.usertype = c.usertype
where o.type = ‘S’
[/sourcecode]
But if you regularly use othter DBMS, then you should use the classic AS alias.
DBSMS that only support AS alias
At least these do not support the = way of specifying an alias:
- Oracle SELECT.
- DB/2 subselect.
- Firebird.
- InterBase.
–jeroen
via: Aaron Bertrand : Bad Habits to Kick : Using AS instead of = for column aliases.






Leave a Comment