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 |
|
wisdomtree2009
Starting Member
5 Posts |
Posted - 2009-01-08 : 01:30:20
|
| HiI have two tables A and B with common column c1. these two tables are in two databases db1 and db2. How can i retrieve the data by joining the two tables. Any help Appreciated |
|
|
Jai Krishna
Constraint Violating Yak Guru
333 Posts |
Posted - 2009-01-08 : 01:35:18
|
| SELECT * FROM databasename1..tablename1 t1inner join databasename2..tablename2 t2 on (t1.commoncol =t2.commoncol)Jai Krishna |
 |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-01-08 : 01:36:10
|
| select * from db1.taba as a inner join db2.tabb as b on ( a.c1 = b.c1) |
 |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-01-08 : 01:49:09
|
| using schema,select * from Databasename.Schemaname.table1 AS t1INNER JOIN Databasename.Schemaname.table2 AS t2 ON (t1.c1 = t2.c1)without using schema,select * from Databasename..table1 AS t1INNER JOIN Databasename..table2 AS t2 ON (t1.c1 = t2.c1) |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-08 : 01:50:50
|
| Assuming dbs are on same server all above solutions will work. Just in case, they are on different server, you need to configure linked server b/w them or use OPENROWSET() |
 |
|
|
|
|
|