Using sp_addlinkedserver to implement remote database linking

Source: Internet
Author: User
Tags aliases

--To view the current link situation:Select *  fromsys.servers;--use Sp_helpserver to display the available serversExecsp_helpserver--Delete a link that already existsExecSp_droplinkedsrvlogin server aliases,NullExecsp_dropserver Server Aliases--use sp_addlinkedserver to add linksEXECsp_addlinkedserver@server='192.168.2.66',--the server alias being accessed (used to directly use the target server IP, or to take an individual name such as: JOY)@srvproduct="',@provider='SQLOLEDB',@datasrc='192.168.2.66' --the server to access--use sp_addlinkedsrvlogin to add user login linksEXECsp_addlinkedsrvlogin'192.168.2.66',--the server alias being accessed (if you use the alias joy in sp_addlinkedserver above, this is joy too)'false',NULL,'SA',--Account Number'test123' --PasswordUse an example (access the database music on the target server to view the contents of the table test): If the alias is the target server IP, 192, when the link is established.168.2. theThen:Select *  from [192.168.2.66].[Music]. Dbo.test If the alias is joy when the link is established, then:Select *  from [JOY].[Music]. Dbo.test may encounter problems:execSp_dropserver'JOY'execution failure, error message: There is still a server'JOY'telnet or link to login. Workaround:execSp_droplinkedsrvlogin'JOY',NULLexecSp_dropserver'JOY'

Source: http://blog.sina.com.cn/s/blog_4c197d4201017aoq.html

Using sp_addlinkedserver to implement remote database linking

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.