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