Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 aliasing tablenames

Author  Topic 

mike123
Master Smack Fu Yak Hacker

1462 Posts

Posted - 2008-09-03 : 08:00:18
Hi,

I was taught that using aliases for your table names was always faster, so when they are referenced again the TSQL engine does not have to lookup the table again.

I always stick to this practice, just wondering if there is a definate speed improvement ( i have an older project in which I will upgrade all the SPROCS that do not follow this practice)

thanks for any info!
mike123

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-09-03 : 09:04:48
There is no speed improvement for using aliases. SQL Server uses an identity value for the table names and colum names.
Aliases is mostly good for readability of code.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2008-09-03 : 11:25:02
And for table variables. You can't join to a table variable directly -- you have to use an alias.

-------------
Charlie
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2008-09-03 : 11:25:21
And for table variables. You can't join to a table variable directly -- you have to use an alias.

-------------
Charlie
Go to Top of Page

mike123
Master Smack Fu Yak Hacker

1462 Posts

Posted - 2008-09-03 : 16:12:07
quote:
Originally posted by Peso

There is no speed improvement for using aliases. SQL Server uses an identity value for the table names and colum names.
Aliases is mostly good for readability of code.



E 12°55'05.63"
N 56°04'39.26"




thx Peso, exactly the answer I was looking for.. Now I understand what happens a little better behind the scenes...

I was thinking it should be like this, but my teacher when I took a SQL course told me otherwise :) regardless I am happy Im following best practice


Cheers,
mike123
Go to Top of Page

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2008-09-03 : 16:29:45
Aliasing tables improves readability of code only if your actual table names are unreadable.

Aliasing tables is NOT universally considered "best practice".

But we have had this exact same discussion before right here:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=81222


Boycotted Beijing Olympics 2008
Go to Top of Page
   

- Advertisement -