1

I want to join tables from two different linked servers. I am not sure how to do that.

First query:

SELECT * FROM OPENQUERY(PANTS,'
SELECT
LONG
,SHORT
FROM JEANS

Second query:

SELECT * FROM OPENQUERY(SHIRTS,'
SELECT 
WHITE
,BLACK 
 FROM STORES

Let's say long is in the stores table and I want to join on it. How would I do that?

1 Answer 1

2

According to the query you supplied, you could do it like this:

Select Pants.Long, Pants.Short,
    Shirts.White, Shirts.Black
  From OpenQuery(PANTS, 'Select Long, Short From Jeans') As Pants
  Join OpenQuery(SHIRTS, 'Select White, Black, Long From Stores') As Shirts 
    On Pants.Long = Shirts.Long;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.