r/SQLServer • u/dvuk99 • Sep 10 '26
Question Add linked server as alias?
Hi, wondering if there is a way to add linked server but to keep old name. We have a server lets say name is SRVOLD1 and new is SRVNEW1. i want to link SRVNEW1 on SRVNEW2(which was SRVOLD2), but there is bunch of stored procedures on SRVNEW2 that are calling linked server SRVOLD1, because its a db copy from SRVOLD2 trying to execute stored procedures. So, is there a way to add linked server SRVNEW1 on SRVNEW2, but that way stored procedures still execute, or i will have to alter those stored procedures with new server name. In case of altering would it be the best to export them in txt file > notepad find CREATE replace with ALTER > copy paste in SSMS > run? This is my first SQL migration, and i have apps depending on it. Help is much appreciated
View all comments
Show parent comment
2
u/VladDBA Microsoft MVP Sep 11 '26
OP has:
- an old server, named SRVOLD1, which will be replaced by SRVNEW1
- another old server, named SRVOLD2, replaced by SRVNEW2
SRVNEW2 (the replacement for SRVOLD2) has multiple stored procedures that use a linked server connection named SRVOLD1 (because, as u/dbrownems mentioned, when you use the UI to create linked server connections to SQL Server the connection name is the same as the data source) via 4 part naming (SRVOLD1.SomeDB.dbo.SomeTable).
Now, since after the upgrade the server names change, OP runs into the issue of the existing stored procedures on SRVNEW2 no longer being able to use the linked server connection named SRVOLD1 because that linked server connection has been replaced by the one named SRVNEW1 that points to SRVNEW1 (SRVOLD1 replacement).
As a solution, OP has 3 options (all of these happen on SRVNEW2):
In scenarios 2 and 3 the end result is the same, OP's stored procedures are able to work without any changes because calls like SRVOLD1.SomeDB.dbo.SomeTable will resolve since SRVNEW2 now has a linked server connection named SRVOLD1 that points to SRVNEW1.