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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s