How to update a linked server connection string?

12,937

To change server name of the linked server use sp_setnetname. Changing other things doesn't make sense (eg provider) which is why there is no alter proc.

In this case it won't work because you haven't followed the sp_addlinkedserver example. In fact, I can't see why you'd set up a linked server to SQL Server this way. You'd use sp_addlinkedsrvlogin for credentials too

EXEC sp_addlinkedserver
  @server = 'north',
  @srvproduct = 'SQL Server'
GO
EXEC sp_setnetname 'north', '192.168.100.147'
GO
EXEC sp_addlinkedsrvlogin 'north', NULL, NULL, 'sa', 'XXXX'
GO

If you don't want to do it this way, then drop and recreate it however you want. That is, you have to drop and recreate it because you have set this up in a non-standard fashion

Share:
12,937

Related videos on Youtube

Raymond Morphy
Author by

Raymond Morphy

Time passes soon but just memories remain, and it's better to good memories remain!!

Updated on June 04, 2022

Comments

  • Raymond Morphy
    Raymond Morphy almost 2 years

    I'm using below statement for addling a linked server:

    EXEC sp_addlinkedserver
    @server = 'north',
    @srvproduct = '',
    @provider = 'MSDASQL',
    @provstr = 'DRIVER={SQL Server};SERVER=192.168.100.147;UID=sa;PWD=xxxx;'
    

    Now I want to update the linked server connection string, for example the server name and etc. Is there any statement to do it?

    • OMG Ponies
      OMG Ponies about 13 years
      Just as easy to drop & recreate the object...