Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-03-12 : 09:38:41
|
| Bharath writes "Hi, Let us take the following caseThere are two servers having one database eachand i want to write a query using a INNER join or outer JOINto fetch data using the two databases how to do this?.how to link the two databases?(linked servers concept?)please reply back on this mail i would be thrilled to getan answer for this questionregardsBharath" |
|
|
joldham
Wiseass Yak Posting Master
300 Posts |
Posted - 2002-03-12 : 10:19:22
|
| First, you would need to create a linked server from one of the databases. Then in your SQL statement in the FROM clause, use the following syntax to select the table or view in the other database:Servername.Databasename.owner.tableIf Server2 had Database2, Table2 and the linked server was Server1 and had Database1 with Table1 the statement would look something like:SELECT a.*, b.*FROM Server1.Database1.dbo.Table1 a, Table2 bWhere a.ID = b.IDetc., etc., etc.Someone else in the forum may have a better idea. Let me know if this doesn't satisfy your questions.Jeremy |
 |
|
|
Onamuji
Aged Yak Warrior
504 Posts |
Posted - 2002-03-12 : 13:36:54
|
| OPENROWSET works too... but linked servers are nice too... |
 |
|
|
|
|
|