Click here to Skip to main content
13,191,877 members (54,489 online)
Rate this:
Please Sign up or sign in to vote.
I have two ms sql table in two different instances. I want to join that two tables and get the result. Is it possible.

For example
Databse 1, Databse 2

Database 1 is in instance 1(sql Server 1)
Databse 2 is in instance 2 (sql server 2)

Posted 2-Aug-12 23:59pm
Updated 3-Aug-12 0:14am
digimanus 3-Aug-12 6:07am
why not joning in 1 query?
what do you mean by 2 different instances? two servers?
Soft009 3-Aug-12 6:12am
same server two sql instances..
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You should use a fully qualified name of the objects you are using.
Try this:
SELECT E.ID, E.Name, E.Address, C.Code, C.Mobile FROM Database1.DBO.tbEmployee E INNER JOIN Database2.DBO.tbEmployeeDtls C ON E.ID = C.ID

Refer the links below:[^][^]

Soft009 8-Aug-12 1:05am
I can use this query when the databases are in the same instance(server) but in by case the databases are in two different instances (servers).
_Amy 8-Aug-12 1:08am
Use server1.Database1.DBO.tbEmployee. As I told fully qualified...
Soft009 8-Aug-12 1:21am
Thanks i'll try....
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

1)Linked server can used for connection purpose..
2)select * from [LocalTablename] as t1 where not exists (SELECT * FROM [Linkedservername].IAT.dbo.destinationtable as t2 where t1.Id=t2.Id)
above use for comapare local table and destination table.

3)select * from [Linkedserver].IAT.dbo.destinationtable it is use for see data for another instance data.
4)copy into temporary table .
Then you can do any operation on it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.171017.2 | Last Updated 24 Aug 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100