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 |
shabar
Starting Member
4 Posts |
Posted - 2010-09-09 : 07:12:12
|
HiHow to compare two fields in two separate SQL server databases.CheersShabar |
|
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts |
Posted - 2010-09-09 : 07:37:59
|
what comparison do you want to run ? sample data and output will help. |
|
|
shabar
Starting Member
4 Posts |
Posted - 2010-09-09 : 15:10:39
|
quote: Originally posted by sakets_2000 what comparison do you want to run ? sample data and output will help.
HiBasically 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 senseCheersShabar |
|
|
shabar
Starting Member
4 Posts |
Posted - 2010-09-13 : 15:33:38
|
HiCan we implement following format to access two databases quote: select *from currentDB_table cdb, remoteDB_table@REMOTEDBLINK rdbwhere cdb.field1 = rdb.field1
CheersShabar |
|
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2010-09-13 : 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 hereinner join MyOtherDatabase.dbo.MyOtherTable there on here.MyColumn = there.MyColumnIf 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 - 2010-09-14 : 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 hereinner join MyOtherDatabase.dbo.MyOtherTable there on here.MyColumn = there.MyColumnIf 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 KoolIt's great CheersShabar |
|
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2010-09-14 : 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 hereinner join MyOtherDatabase.dbo.MyOtherTable there on here.MyColumn = there.MyColumnIf 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) |
|
|
|
|
|
|
|