The server 'MyServer' already exists.

  • 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

  • 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

    BEGIN

    PRINT 'DO SOMETHING ELSE'

    END

  • 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