Could not find server 'server name' in sys.servers. SQL Server 2014

后端 未结 3 1302
迷失自我
迷失自我 2021-01-03 23:34

I recently upgraded our SQL Server from 2005 to 2014 (linked server) and I am noticing that one of the stored procedures which calls the exec command to execute a stored pro

相关标签:
3条回答
  • 2021-01-03 23:58

    I had the problem due to an extra space in the name of the linked server. "SERVER1, 1234" instead of "SERVER1,1234"

    0 讨论(0)
  • 2021-01-04 00:07

    At first check out that your linked server is in the list by this query

    select name from sys.servers
    

    If it not exists then try to add to the linked server

    EXEC sp_addlinkedserver @server = 'SERVER_NAME' --or may be server ip address
    

    After that login to that linked server by

    EXEC sp_addlinkedsrvlogin 'SERVER_NAME'
                             ,'false'
                             ,NULL
                             ,'USER_NAME'
                             ,'PASSWORD'
    

    Then you can do whatever you want ,treat it like your local server

    exec [SERVER_NAME].[DATABASE_NAME].dbo.SP_NAME @sample_parameter
    

    Finally you can drop that server from linked server list by

    sp_dropserver 'SERVER_NAME', 'droplogins'
    

    If it will help you then please upvote.

    0 讨论(0)
  • 2021-01-04 00:09

    I figured out the issue. The linked server was created correctly. However, after the server was upgraded and switched the server name in sys.servers still had the old server name.

    I had to drop the old server name and add the new server name to sys.servers on the new server

    sp_dropserver 'Server_A'
    GO
    sp_addserver  'Server',local
    GO
    
    0 讨论(0)
提交回复
热议问题