Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Browse by Tags · View All
sql_server 217
t-sql 211
tsql 116
sqlserver 96
BRH 78
#SQLServer 66
#TSQL 56
SQL Server 34
function 11
SSMS 9

Archive · View All
August 2007 17
August 2010 8
June 2012 7
June 2011 7
November 2007 7
August 2012 6
May 2012 6
November 2011 6
August 2011 6
October 2011 6

Madhivanan's TSQL Blog

Different ways to alias a column

Nov 22 2010 2:34AM by Madhivanan   

I have already posted blog posts regarding the proper usage of the alias name

http://beyondrelational.com/blogs/madhivanan/archive/2007/11/14/should-alias-names-be-preceded-by-as.aspx
http://beyondrelational.com/blogs/madhivanan/archive/2008/09/09/should-alias-names-be-preceded-by-as-part-2.aspx


There are different ways to alias a column. Here are some possible ways that work in SQL Server.

select 
	1 as number,
	1 number,
	1 "number",
	1 'number',
	1number,
	1"number",
	1'number',
	1 as "number",
	1 as 'number',
	1.number,
	1."number",
	1.'number',
	1 as [number],
	1 [number],
	1.[number],
	1[number]	

But I prefer the following as other methods may be confusing or misleading

select 
	1 as number,
	1 as [number]

Tags: t-sql, sql_server, alias_name, sqlserver, tsql, BRH, #TSQL, #SQLServer,


Madhivanan
3 · 40% · 12935
9
 
0
Lifesaver
 
0
Refreshed
 
 
0
Incorrect



Submit

8  Comments  

  • Hi Madhivanan

    I always find your blog quite informative.

    There is one more way we can alias a column

    Select number = 1

    -Chintak

    commented on Nov 22 2010 5:27AM
    Chintak Chhapia
    40 · 5% · 1470
  • Nice madhi sir...

    commented on Dec 8 2010 11:11PM
    Haripriya
    2216 · 0% · 6
  • And of course you can alias columns in a subquery (or APPLY) like this:

    SELECT a.number FROM (SELECT 1) a(number)

    commented on Dec 17 2010 7:05AM
    MisterMagoo
    48 · 4% · 1213
  • really informative...!

    commented on Dec 18 2010 5:05AM
    abdulmajid
    2076 · 0% · 7
  • I found it informative too. Thanks for sharing.

    RIBA

    commented on Oct 17 2012 1:39AM
    alexanderspear
    3065 · 0% · 2
  • Thank you all for your valuable feedbacks

    commented on Oct 17 2012 2:39AM
    Madhivanan
    3 · 40% · 12935
  • Following methods work with constants only:

    1.number
    1.number,
    1."number"
    1.'number'
    

    If you try to do this,

    select P.Product_Id.[number] from [Product] P
    

    you will get an error "Cannot call methods on {your column datatype}"

    commented on Oct 17 2012 3:45AM
    Dubelewskyj Oleksandr
    475 · 0% · 81
  • Dubelewskyj Oleksandr , they will work for numbers only. I should have specified it in the post :)

    commented on Oct 17 2012 4:02AM
    Madhivanan
    3 · 40% · 12935

Your Comment


Sign Up or Login to post a comment.

"Different ways to alias a column" rated 5 out of 5 by 9 readers
Different ways to alias a column , 5.0 out of 5 based on 9 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]