Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: SQL SQL-Server-2008
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
Edited 3-Aug-12 0:14am
digimanus at 3-Aug-12 6:07am
why not joning in 1 query?
what do you mean by 2 different instances? two servers?
Soft009 at 3-Aug-12 6:12am
same server two sql instances..
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.
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 at 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 at 8-Aug-12 1:08am
Use server1.Database1.DBO.tbEmployee. As I told fully qualified...
Soft009 at 8-Aug-12 1:21am
Thanks i'll try....

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

  Print Answers RSS
0 OriginalGriff 554
1 Gihan Liyanage 338
2 RyanDev 248
3 Sergey Alexandrovich Kryukov 243
4 ChauhanAjay 220
0 Sergey Alexandrovich Kryukov 9,011
1 OriginalGriff 7,941
2 CPallini 2,603
3 Richard MacCutchan 2,121
4 Abhinav S 1,928

Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 24 Aug 2012
Copyright © CodeProject, 1999-2014
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