SQL Query to Add a Linked Server

The following SQL query will add the linked server SQLSERVERINSTANCE with the server option RPC Out set to True and specifies that connections to the remote server from logins that are not explicitly mapped will be made using the login’s current security context:

USE [master]
GO
EXEC master.dbo.sp_addlinkedserver @server = N'SQLNVT08NP2010', @srvproduct=N'SQL Server'
GO
EXEC master.dbo.sp_serveroption @server=N'SQLNVT08NP2010', @optname=N'rpc out', @optvalue=N'true'
GO
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname = N'SQLNVT08NP2010', @locallogin = NULL , @useself = N'True'
GO

The sp_addlinkedsrvlogin parameters could also be simplified to just the following:

EXEC master.dbo.sp_addlinkedsrvlogin 'SQLNVT08NP2010', 'True'

Leave a Reply

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