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 ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 |
| ||||
| 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) |