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)
 OPENQUERY Query

Author  Topic 

bendertez
Yak Posting Veteran

94 Posts

Posted - 2008-08-01 : 06:32:19
Hello

I'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

Hello

I'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?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

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)
Go to Top of Page

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_REF

would returns columns from both the tables. You need to explicitly name the columns in the SELECT statement


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -