Data Synchronization stored procedure for two servers
Using Stored Procedures: Import four tables in "192.168.100.111" Database "A" to "192.168.100.112" Database "B"
-- Example
Insert OpenRowSet ('sqloledb', '192. 168.100.112 '; 'sa password', database B. DBO. Table 1)
Select *
From OpenRowSet ('sqloledb', '192. 168.100.111'; 'sa '; 'sa password', database A. DBO. Table 1)
Multiple machines are not in the same network and can only be dial-up by modem. How can we implement synchronization?
1. Open the MSDTC Service of the local SQL Server
2. Dial the number to the remote server (modem-to-modem)
3. Add a remote server locally:
Exec sp_addmediaserver @ Server = '192. 168.2.44'
Exec sp_add1_srvlogin @ rmtsrvname = '192. 168.2.44 ',
@ Useself = false,
@ Locallogin = 'sa ',
@ Rmtuser = 'sa ',
@ Rmtpassword = NULL
4. directly use SQL statements to transmit data
Select * from [192.168.2.44]. zlsgl. DBO. t_cby update [192.168.2.44]. zlsgl. DBO. t_cby set XM = rtrim (XM) + '1' where bH = 4
5. Close the connection after completion:
Sp_droplinkedsrvlogin @ rmtsrvname = '192. 168.2.44 ', @ locallogin = 'sa'
Sp_dropserver @ Server = '192. 168.2.44'