The Windows computer has a new name, but SQL Server still remembers the old one. After renaming the Windows server, compare @@SERVERNAME with SERVERPROPERTY before changing dependent services. The metadata correction requires a restart and careful readback.

Confirm the Mismatch Left by Renaming the Windows Server
Run both expressions on the affected instance. For a named instance, the value includes \InstanceName; preserve that suffix when building the new local name. In a cluster or availability group, the meaning of the server name differs from a stand-alone computer rename. Follow the product-specific rename procedure there rather than copying a stand-alone example.
SELECT @@SERVERNAME AS stored_local_name,
CONVERT(sysname,SERVERPROPERTY('ServerName')) AS current_server_name,
CONVERT(sysname,SERVERPROPERTY('MachineName')) AS machine_name,
CONVERT(sysname,SERVERPROPERTY('InstanceName')) AS instance_name;I save the result and the Windows computer name before making a change. Which name do clients use: the machine name, a DNS alias, an availability group listener, or a connection string with an instance name? The answer controls the follow-up tests. Repairing @@SERVERNAME does not update every external reference.
Plan Dependencies Before Renaming the Windows Server
Microsoft's rename guidance places restrictions on installations using replication and on special configurations. Treat replication as a separate migration assessment, not a quick call to sp_dropserver. Inventory publishers, distributors, subscribers, linked servers, maintenance plans, SQL Agent jobs, SSRS, and any service that stores the old name. Confirm a maintenance window because the stored name change requires a SQL Server service restart.
SELECT name,product,data_source
FROM sys.servers
WHERE server_id <> 0;
SELECT name,enabled
FROM msdb.dbo.sysjobs;These lists are starting points, not a complete dependency map. A job can hide the old name in step command text, an SSIS package, or a PowerShell script. Export configuration and keep a verified rollback plan. I test applications through the exact connection names they use, not through localhost alone.
Update the Local Server Entry
For a stand-alone instance supported by the rename procedure, pass the exact old local server name to sp_dropserver, then add the new local server name with local. Do not blindly substitute a linked-server name. Use the values measured in the first query and check them with an operator before execution.
EXEC sys.sp_dropserver @server = N'OLDHOST';
EXEC sys.sp_addserver @server = N'NEWHOST', @local = 'local';For a named instance, use OLDHOST\SQL2019 and NEWHOST\SQL2019 if those are the actual names. Run once in an approved window. If the first call reports dependent remote logins, investigate and remove those dependencies through a planned change rather than retrying at random. Do not use this script on a clustered or replicated instance without its specific guidance.
Restart and Verify
Restart the SQL Server service for the instance so @@SERVERNAME picks up the new local entry. Coordinate the restart with Agent and applications; an unexpected disconnect can turn a small metadata correction into an outage. After restart, run the comparison again and confirm the stored and current names agree for the intended instance.
SELECT @@SERVERNAME AS stored_local_name,
CONVERT(sysname,SERVERPROPERTY('ServerName')) AS current_server_name;
SELECT server_id,name,is_linked
FROM sys.servers WHERE server_id = 0;A correct result here proves the local metadata update, not the whole migration. I then connect from a remote client through the application's configured name and run a small read and write test. Check SQL Server and Agent logs for failures after the restart.

Inspect Jobs and Maintenance Plans
Search job steps for the old name and review each hit in context. A backup job writing to a UNC share, an SSIS step, or a linked-server query can still reference it. Maintenance plans can have connection managers or target server metadata that a simple text search misses. Execute a controlled test of critical jobs and confirm the output destination.
SELECT j.name AS job_name, s.step_id, s.step_name, s.command
FROM msdb.dbo.sysjobsteps AS s
JOIN msdb.dbo.sysjobs AS j ON j.job_id = s.job_id
WHERE s.command LIKE N'%OLDHOST%';Do not do a global string replacement in job commands. The old name can be a historical path or data value, and a new DNS alias can be the intended long-term connection name. I record each confirmed reference and the change owner. Then I compare the next scheduled run with the last healthy run.
Check Logins, Linked Servers and SSRS
Windows logins can contain an old machine name for local accounts or groups. Inspect server principals and map the identities to current Windows accounts. Domain accounts do not automatically change merely because the member server was renamed. Linked-server definitions and credentials deserve separate readback tests. If SSRS is installed, inspect its service URLs, report server database connection, subscriptions, and stored references.
SELECT name,type_desc
FROM sys.server_principals
WHERE name LIKE N'OLDHOST\%';
SELECT name,data_source
FROM sys.servers
WHERE server_id <> 0;I also check application connection strings and DNS records with the infrastructure owner. Those live outside SQL Server metadata. A login failure after rename can be identity, SPN, DNS, or connection configuration; @@SERVERNAME is only one possible cause. Keep the diagnostic scope broad enough to find the actual dependency.
Check Kerberos and Backups After Renaming the Windows Server
Check the SQL Server service account and its Service Principal Names with the infrastructure owner if integrated authentication fails after a rename. Kerberos depends on names beyond @@SERVERNAME; SQL metadata repair does not register every service identity automatically. A client can fall back to another authentication path or fail, so verify the actual authentication scheme on a remote connection. Do not disable authentication protections to make the test pass.
Also inspect backup destinations and monitoring tools that address the machine by name. A successful application query does not prove that overnight backups, alerts, and monitoring collectors can still reach the new host. I compare one full scheduled cycle with the last healthy cycle before closing the rename change.
Record a Clean Completion
Keep before and after results, restart time, client connection tests, critical job outcomes, linked-server checks, and reporting-service checks. If a dependency fails, restore its intended name or configuration rather than undoing the local server name reflexively. A complete change record makes later failures easier to separate from the rename.
I treat renaming the Windows server as an application change. The two name expressions expose the SQL Server mismatch quickly, and sp_dropserver plus sp_addserver fixes that local metadata on a supported stand-alone instance. The real work is tracing where the old name was used and proving each path again after restart.
Related reading on this blog: Fix @@ServerName Property Value When Incorrect and Naming SQL Server Instances So People Understand Them.

A corrected @@SERVERNAME is not a complete rename, it is one part of checking dependent services.
Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.
Discover more from SQL Authority with Pinal Dave
Subscribe to get the latest posts sent to your email.



