SQL Two database data inserts from different IPs,

Source: Internet
Author: User


Simple example:
//Create Linkserver
exec sp_addlinkedserver ' srv_lnk ', ' ', ' SQLOLEDB ', ' Server name '
//Login Linkserver
exec sp_addlinkedsrvlogin ' Srv_lnk ', ' false ', NULL, ' username ', ' password '
//Query the table of linkserver database Databasea TableA
Select * from Srv_lnk. DataBaseA.dbo.TableA
//list The tables in the linked server
EXEC sp_tables_ex txtsrv

Here is the code that executes the pass,

--Execute here first
EXEC sp_addlinkedserver ' Xhlink ', ', ' SQLOLEDB ', ' 10.0.0.27 '
EXEC sp_addlinkedsrvlogin ' Xhlink ', ' false ', NULL, ' sa ', ' ****** '
--Execute here again, can't execute together
INSERT INTO XH
SELECT * from XHLink.marketing.dbo.xh
where xh_bm= ' 0607 ' and xh_rq= ' 2015/01/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= ' 0607 ' and xh_rq= ' 2015/01/03 '
)



The above through two places to learn from, to detail can see the following two blog

http://blog.csdn.net/htl258/article/details/5695391

http://blog.csdn.net/postfxj/article/details/21405711

SQL Two database data inserts from different IPs,

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.