[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

OPENQUERY INNER JOIN on two Remote Tables

Posted on 2004-10-06
3
Medium Priority
?
7,518 Views
Last Modified: 2008-01-09
I have two remote tables where I need have an INNER JOIN with OPENQUERY

This is what I want to do in regular SQL without OPENQUERY

SELECT * FROM hmodta.hmembp AS a
INNER JOIN mcnet..user_header AS p
ON a.SUBNO+a.PERNO = p.ExternalSystemKey
ORDER BY a.SUBNO DESC

Here is what I have for OPENQUERY.  The 2 remote servers are AS400 and WEBSRVR

SELECT * FROM
OpenQuery(AS400, 'SELECT * FROM hmodta.hmembp AS a INNER JOIN')
OpenQuery(WEBSRVR2, 'mcnet..user_header AS p ON a.SUBNO concat a.PERNO = p.ExternalSystemKey ORDER BY a.SUBNO DESC')

I know this isn't right, but could someone give me assistance?  Thanks in advance

0
Comment
Question by:vikingg97
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
miron earned 2000 total points
ID: 12242416
SELECT * FROM
OpenQuery(AS400, 'SELECT * FROM hmodta.hmembp')  as a INNER JOIN
OpenQuery(WEBSRVR2, 'mcnet..user_header')  AS p ON a.SUBNO concat a.PERNO = p.ExternalSystemKey ORDER BY a.SUBNO DESC
0
 
LVL 1

Author Comment

by:vikingg97
ID: 12242600
I needed to modify it a little to narrow the results, so here is what I did and the error I get. Do I need to do something different?

SELECT * FROM
OpenQuery(AS400, 'SELECT * FROM hmodta.hmembp')  as a INNER JOIN
OpenQuery(WEBSRVR2, 'mcnet..user_header')  AS p ON a.SUBNO + a.PERNO = p.External_System_Key  
WHERE a.cgrpid = 'S0038A'
ORDER BY a.SUBNO DESC

Error:
Server: Msg 2809, Level 18, State 1, Line 1
The request for procedure 'User_Header' failed because 'User_Header' is a table object.

0
 
LVL 1

Author Comment

by:vikingg97
ID: 12243083
Nevermind I figured it out. I needed to change it to this.  Also narrow down the fields.

Thanks for setting it up miron.

Solution:
SELECT * FROM
OpenQuery(AS400, 'SELECT SUBNO, PERNO, cgrpid FROM hmodta.hmembp') as a INNER JOIN
OpenQuery(WEBSRVR2, 'SELECT External_System_Key, User_ID FROM mcnet..user_header')  AS p ON a.SUBNO + a.PERNO = p.External_System_Key  
WHERE a.cgrpid = 'M00005'
ORDER BY a.SUBNO DESC
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have a large data set and a SSIS package. How can I load this file in multi threading?
Ready to get certified? Check out some courses that help you prepare for third-party exams.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how the fundamental information of how to create a table.

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question