Unix Technical Forum

Query returning duplicate field names

This is a discussion on Query returning duplicate field names within the SQL Server forums, part of the Microsoft SQL Server category; --> I have a .NET program that can connect to either an Access 97 database or an SQL Server 7 ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 04:24 AM
Don
 
Posts: n/a
Default Query returning duplicate field names

I have a .NET program that can connect to either an Access 97 database or an
SQL Server 7 database. In the database I have two tables which have a field
called ID. When I run a query like "SELECT A.*, B.* FROM A, B", the query
returns those fields as "A.ID" and "B.ID" when connected to Access 97, but
as "ID" and "ID" in SQL Server 7. Is there anyway to get SQL Server to
prepend the table name to the field name in a case like this and not return
duplicate field names like that without having to specify aliases for the
fields?

- Don


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 04:25 AM
Hugo Kornelis
 
Posts: n/a
Default Re: Query returning duplicate field names

On Thu, 30 Sep 2004 14:52:36 GMT, Don wrote:

>I have a .NET program that can connect to either an Access 97 database or an
>SQL Server 7 database. In the database I have two tables which have a field
>called ID. When I run a query like "SELECT A.*, B.* FROM A, B", the query
>returns those fields as "A.ID" and "B.ID" when connected to Access 97, but
>as "ID" and "ID" in SQL Server 7. Is there anyway to get SQL Server to
>prepend the table name to the field name in a case like this and not return
>duplicate field names like that without having to specify aliases for the
>fields?
>
>- Don
>


Hi Don,

No. You'll have to use aliases.

(Or - much better! - specify a column list instead of using SELECT *)

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:53 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com