SQL inserts data from two databases with different ip addresses, and sqlip
Simple Example:
// Create a linkServer
Exec sp_addmediaserver 'srv _ lnk ', '', 'sqloledb', 'server name'
// Log on to the linkServer
Exec sp_add1_srvlogin 'srv _ lnk ', 'false', null, 'username', 'Password'
// Query Table A of the database DataBaseA of the linkServer
Select * From srv_lnk.DataBaseA.dbo.TableA
// List the tables in the linked server
EXEC sp_tables_ex txtsrv
The following code is executed,
-- Execute this command first
EXEC sp_addrole server 'xhlink', '', 'sqloledb', '10. 0.0.27'
EXEC sp_add1_srvlogin 'xhlink', 'false', null, 'sa ','******'
-- Run the command again. The command cannot be executed together.
Insert into xh
SELECT * FROM XHLink. marketing. dbo. xh
Where xh_bm = '20180101' and xh_rq = '2018/03'
Insert into xhmx
SELECT * FROM XHLink. marketing. dbo. xhmx
Where xhmx_dh in
(
SELECT xh_dh FROM XHLink. marketing. dbo. xh
Where xh_bm = '20180101' and xh_rq = '2018/03'
)
The above are learned from two places. For details, refer to the following two blogs:
Http://blog.csdn.net/htl258/article/details/5695391
Http://blog.csdn.net/postfxj/article/details/21405711