Creating a link between two SQL servers

To create a link between two SQL Servers you need to use the sp_addlinkedserver and sp_addlinkedsrvlogin stored procedures.
First,

sp_addlinkedserver @server='DBLINK01',@srvproduct='',@provider='SQLOLEDB',@datasrc='SQL-HOU-01';

Where,
@server is the name of the link
@srvproduct is the type of product, by default SQL Server
@datasrc is the server you link to
Then, you need to set the username and password to use on the link.

sp_addlinkedsrvlogin 'DBLINK01','false',null,'sa','Pa$$w0rd';

The first parameter is the name of the link to use,
The fourth is the account of the remote server to use,
The fifth is the password for the account.

Leave a Reply

Your email address will not be published. Required fields are marked *