Tuesday, February 28, 2012

Aliasing Column Names


Today, I discovered a new way columns can be aliased.

select o.*
from
(
      select id, name, xtype
      from sys.sysobjects
) o
join sys.syscomments c on o.id = c.id

select o.*
from
(
      select id as a, name as b, xtype as c
      from sys.sysobjects
) o
join sys.syscomments c on o.a = c.id

select o.*
from
(
      select id, name, xtype
      from sys.sysobjects
) o (a, b, c)
join sys.syscomments c on o.a = c.id

No comments:

Post a Comment