rva1945
SSC Veteran
Points: 206
More actions
December 17, 2007 at 6:06 am
#177516
The server is already linked by using sp_addlinkedserver, is there any way to know IF it EXISTS in order to avoid the message? And how do I remove it (something "sp_removelinkedserver" or so) ?
Thanks
Tommy Bollhofer
SSChampion
Points: 14940
December 17, 2007 at 7:10 am
#760665
Use sp_dropserver to remove a linked server.
IF EXISTS (SELECT name FROM sys.servers WHERE (server_id != 0) AND [name] = 'SOMELINKEDSERVER')
BEGIN
PRINT 'sp_dropserver @server=''SOMELINKEDSERVERNAME'''
END
ELSE
PRINT 'DO SOMETHING ELSE'
Tommy
Steve Jones - SSC Editor
SSC Guru
Points: 736255
December 17, 2007 at 8:47 am
#760717
Or just the first part as a test.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply