SQL inserts data from two databases with different ip addresses, and sqlip

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.