S..
S..

Reputation: 1272

Inner Join on 2 tables(both on different Servers)

Is it possible to do an inner join on 2 tables where both the tables are on different server??

Upvotes: 0

Views: 1335

Answers (4)

Ralf de Kleine
Ralf de Kleine

Reputation: 11734

Add a linked server (B) to server A then write the following query

SELECT
    *
FROM
    [SERVERB].[DATABASE].[SCHEMA].[TABLE] A
    INNER JOIN [SERVERA].[DATABASE].[SCHEMA].[TABLE] B ON A.ID = B.ID

Upvotes: 1

Chandu
Chandu

Reputation: 82913

If you are using SQL Server try using a Linked Server, if Oracle use a database link. I am not sure how it would be achieved in the rest.

Upvotes: 0

HLGEM
HLGEM

Reputation: 96572

It is certainly possible in SQL code. How you would do it in C# I don't know but in SQl Server, I would set up linked servers and then the code is:

select t1.field1, t2.field2
From server1.database1.dbo.table1 t1
join server2.database2.dbo.table2 t2
    on t1.id = t2.id

So you just use the four part name instead of the three part name. But you do have to have a linked server set up first.

Upvotes: 1

SLaks
SLaks

Reputation: 887449

You can download both tables to the client, then perform a join using LINQ.

For more detail, please provide more details.

Upvotes: 0

Related Questions