How to use sp_addlinkedserver to implement remote database linking

Source: Internet
Author: User

Using Sp_addlinkeserver for remote database connection can put data of multiple databases into a database,

Or if you have set operation permissions, we can query, back up data and so on in this way.

First, we're going to create a connection

Perform sp_addlinkedserver for connection creation, as follows:

EXEC sp_addlinkedserver
@server = ' ITSV1 ',--the server alias being accessed (used to directly use the destination server IP, or take an individual name such as: LINK1)
@srvproduct = ' ',
@provider = ' SQLOLEDB ',
@datasrc = ' 114.215.86.37,9000 '--the server to be accessed

Second, create a login link

Execute sp_addlinkedsrvlogin to create the login link as follows:

EXEC sp_addlinkedsrvlogin
' Itsv1 ',--the server alias being accessed (if the alias joy is used in the sp_addlinkedserver above, this is joy too)
' False ',
Null
' Sjcx ',--account number
' Sjcx '--Password

--To see if the link was created successfully select * from Sys.servers; View the currently linked server condition exec sp_helpserver

Finally, when we don't use a link, we can delete it

Exec sp_droplinkedsrvlogin Server alias, nullexec sp_dropserver Server alias Note the order of operations at this point is to remove the login link before removing the server link.

How to use 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.