sp_Blitz® Result: @@ServerName Not Set

"Who am I, really?"

“Who am I, really?”

The @@ServerName refers to the local server that SQL Server is running on.  This property is set during installation, but there are instances where @@ServerName may be NULL or may not be correct.

Running the following will show the current TSQL value for this property:


This part of our SQL Server sp_Blitz® script checks @@SERVERNAME to make sure it’s set.

To Fix the Problem

If the @@ServerName property is NULL, running the following will fix the issue- but only after you restart the SQL Server instance. Yep, fixing this requires an outage.

exec sp_addserver '<LocalServerName>', local;

If the @@ServerName property is incorrect, run the following to correct the issue:

exec sp_dropserver 'old_name';
exec sp_addserver 'new_name', 'local';

Return to sp_Blitz® or Ask Us Questions