| Author |
Topic  |
|
|
shabar
Starting Member
4 Posts |
Posted - 09/09/2010 : 07:12:12
|
Hi
How to compare two fields in two separate SQL server databases.
Cheers
Shabar |
|
|
sakets_2000
Flowing Fount of Yak Knowledge
India
1472 Posts |
Posted - 09/09/2010 : 07:37:59
|
| what comparison do you want to run ? sample data and output will help. |
 |
|
|
shabar
Starting Member
4 Posts |
Posted - 09/09/2010 : 15:10:39
|
quote: Originally posted by sakets_2000
what comparison do you want to run ? sample data and output will help.
Hi
Basically I want to run one SQL script to compare two tables fields in two separate SQL sever databases.
Say I have table T1 in database DB1 and table T2 in database DB2.
Hope this make sense
Cheers
Shabar
|
 |
|
|
shabar
Starting Member
4 Posts |
Posted - 09/13/2010 : 15:33:38
|
Hi
Can we implement following format to access two databases
quote:
select * from currentDB_table cdb , remoteDB_table@REMOTEDBLINK rdb where cdb.field1 = rdb.field1
Cheers
Shabar |
 |
|
|
Bustaz Kool
Flowing Fount of Yak Knowledge
USA
1429 Posts |
Posted - 09/13/2010 : 19:21:07
|
If the two databases are on the same SQL Server instance, you can simply use a three part name for the "remote" database:
select here.* from MyLocalTable here inner join MyOtherDatabase.dbo.MyOtherTable there on here.MyColumn = there.MyColumn
If the other database is on another instance, you could define a linked server relationship to that database and then use a four part name (LinkedServerName.Dataqbase.Schema.Object) to access the remote item.
======================================= In all life one should comfort the afflicted, but verily, also, one should afflict the comfortable, and especially when they are comfortably, contentedly, even happily wrong. -John Kenneth Galbraith, economist (1908-2006) |
 |
|
|
shabar
Starting Member
4 Posts |
Posted - 09/14/2010 : 06:14:57
|
quote: Originally posted by Bustaz Kool
If the two databases are on the same SQL Server instance, you can simply use a three part name for the "remote" database:
select here.* from MyLocalTable here inner join MyOtherDatabase.dbo.MyOtherTable there on here.MyColumn = there.MyColumn
If the other database is on another instance, you could define a linked server relationship to that database and then use a four part name (LinkedServerName.Dataqbase.Schema.Object) to access the remote item.
======================================= In all life one should comfort the afflicted, but verily, also, one should afflict the comfortable, and especially when they are comfortably, contentedly, even happily wrong. -John Kenneth Galbraith, economist (1908-2006)
Thanks very much Bustaz Kool
It's great
Cheers
Shabar
|
 |
|
|
Bustaz Kool
Flowing Fount of Yak Knowledge
USA
1429 Posts |
Posted - 09/14/2010 : 17:19:25
|
If the two databases are on the same SQL Server instance, you can simply use a three part name for the "remote" database:
select here.* from MyLocalTable here inner join MyOtherDatabase.dbo.MyOtherTable there on here.MyColumn = there.MyColumn
If the other database is on another instance, you could define a linked server relationship to that database and then use a four part name (LinkedServerName.Dataqbase.Schema.Object) to access the remote item.
======================================= In all life one should comfort the afflicted, but verily, also, one should afflict the comfortable, and especially when they are comfortably, contentedly, even happily wrong. -John Kenneth Galbraith, economist (1908-2006) |
 |
|
| |
Topic  |
|