You are here: Re: Ambiguous Column Names in Multi-Table Join « MsSQL Server « IT news, forums, messages
Re: Ambiguous Column Names in Multi-Table Join

Posted by Erland Sommarskog on 06/21/06 21:39

Mike S (mgspross@netscape.net) writes:
> I was actually thinking about doing it that way, just aliasing all the
> columns. I was hoping to avoid that because it would involve changing a
> number of existing queries/program code - plus most of the queries are
> 'SELECT * FROM Table" type queries, so to produce the same results, I'd
> have to alias every single column in each table. For this particular
> project, I think it might be easier to deal with names like Id, Id1,
> Id2, etc., even though it's not very readable...oh well, just a matter
> of adding extra comments to the source code ;-)

If you have a lot of SELECT * then you have a lot of code to modify.
SELECT * does not belong in production code.

I don't know where you got the idea of Id1 from; SQL Server returns a
result set with two columns that have the same name.

Besides, if the id is a join column, there is little reason to return
it twice...


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация