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
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'
as alias
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'
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.
Filed under: Access, Database Development, DB2, Development, Firebird, InterBase, MySQL, OracleDB, Paradox, PostgreSQL, SQL, SQL Server, Sybase
