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.
| Author |
Topic |
|
bendertez
Yak Posting Veteran
94 Posts |
Posted - 2008-08-01 : 06:32:19
|
| HelloI'm trying to join two tables through a OPENQUERY query, where both primary key fields have the same name:As a result I get the following error: Duplicate column names are not allowed in result sets obtained through OPENQUERY and OPENROWSET. The column name "PERSON_REF" is a duplicate.Is there anyway of overcoming this or is this just a OPENQUERY thing?Thanks |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-08-01 : 06:35:16
|
quote: Originally posted by bendertez HelloI'm trying to join two tables through a OPENQUERY query, where both primary key fields have the same name:As a result I get the following error: Duplicate column names are not allowed in result sets obtained through OPENQUERY and OPENROWSET. The column name "PERSON_REF" is a duplicate.Is there anyway of overcoming this or is this just a OPENQUERY thing?Thanks
Can you post the query you used?MadhivananFailing to plan is Planning to fail |
 |
|
|
bendertez
Yak Posting Veteran
94 Posts |
Posted - 2008-08-01 : 07:12:11
|
| No Probs...OPENQUERY(NID, 'SELECT * FROM DEMO.D500M, DEMO.D550M where DEMO.D500M.PERSON_REF=DEMO.D550M.PERSON_REF) |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-08-01 : 07:23:35
|
quote: Originally posted by bendertez No Probs...OPENQUERY(NID, 'SELECT * FROM DEMO.D500M, DEMO.D550M where DEMO.D500M.PERSON_REF=DEMO.D550M.PERSON_REF)
What are you trying to do with this query?SELECT * FROM DEMO.D500M, DEMO.D550M where DEMO.D500M.PERSON_REF=DEMO.D550M.PERSON_REFwould returns columns from both the tables. You need to explicitly name the columns in the SELECT statementMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|