Thursday, 3 December 2015

All about sp_addlinkedserver syntax

sp_addlinkedserver linked 2 servers. Once sp_addlinkedserver query executes, query can be run against these servers.

Run below queries one by one to link, to provide login credentials and to access data

EXEC sp_addlinkedserver @server='ServerName'
EXEC sp_addlinkedsrvlogin 'ServerName', 'false', NULL, 'username', 'password'
select * from [ServerName].[DBName].[DBO].[TableName]

Once your requirement is done, you may drop the linking by running following query.
EXEC sp_dropserver 'ServerName', 'droplogins'

No comments:

Post a Comment

Dear Readers, Please post your valuable feedback in the comment section if you like this blog or if you have any suggestions. I would love to hear the same from you. Thanks