I have two (linked) Microsoft SQL servers with basically the same setup but they differ in the content. Connection with servers is slow. Some tables contains lot of rows. Some records differ in the fields. Data on each servers match for 99%
I need to merge data from one server to other with minimum traffic transfer.
For example:
SERV1.DB1.dbo.Table:
| fname | count |
----------------------
| 'file1.txt' | 10 |
| 'file2.txt' | 5 |
| 'file3.txt' | 35 |
SERV2.DB2.dbo.Table:
| fname | count |
----------------------
| 'file1.txt' | 40 |
| 'file2.txt' | 150 |
And I want to update SERV2.DB2.dbo.Table to:
| fname | count |
----------------------
| 'file1.txt' | 10 |
| 'file2.txt' | 5 |
| 'file3.txt' | 35 |
I can:
- Drop SERV2.DB2.dbo.Table and restore from backup SERV1.DB1.dbo.Table to SERV2
Plus: Simple
Minus: Slow for big databases
- Use JOIN\UPDATE\INSERT or MERGE\UPDATE\INSERT constructions with camparing each field
Plus: Simple
Minus: Slow for big tables
Minus: Lot of data transferring
- Add and calculate HASH column on each row using all fields and then MERGE\UPDATE\INSERT for update only difference rows
Plus: Transferring only hashes for all rows plus rows for update
Minus: Altering tables
Minus: Calculating
Minus: Much more work for lot of tables
- Use tablediff Utility
Plus\Minus: ??? Is is it useful in this case? How did it works with slow connection?
Is there any more useful way to merge data from one server to other with minimum traffic transfer?
UPD: slow connection channel is the reason to optimize traffic. For tables with lot of records compare each record in both tables or copy full table\database will take lot of time.