SQL Query to Determine if Linked Server Entry Exists

Here’s a simple query to determine whether a server has been added to the Linked Servers list:

IF EXISTS (select 1 from [master].[dbo].[sysservers] WHERE srvname = 'LinkedServerName')
BEGIN
PRINT 'Yes'
END
ELSE
BEGIN
PRINT 'No'
END

The above script can be used as the basis for automatically adding a SQL server to the Linked Server list on a given instance.

Leave a Reply

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