Could not find server 'server name' in sys.servers. SQL Server 2014
I had the problem due to an extra space in the name of the linked server. "SERVER1, 1234" instead of "SERVER1,1234"
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.
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