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’

Leave a Comment

RSS
YouTube
YouTube
Instagram