The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,604 other followers

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

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:

–jeroen

via: Aaron Bertrand : Bad Habits to Kick : Using AS instead of = for column aliases.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

 
%d bloggers like this: