3

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?

5
  • 2
    Just as easy to drop & recreate the object... Commented May 1, 2011 at 4:52
  • My remote database is using for replication, isn't there any problem if I do it? Commented May 1, 2011 at 4:55
  • My remote database uses "transactional replication" and it is as "publisher" an my database wants to connect to it with linked server Commented May 1, 2011 at 5:05
  • @Raymond Morphy, so, which of the servers has the linked server defined? Your database? if so, then it's safe to drop and recreate the linked server. Commented May 1, 2011 at 5:39
  • I linked to that database which is doing replicatiion? Commented May 1, 2011 at 5:45

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.