when you run SELECT @@SERVERNAME, it may return NULL / Wrong Server name.
Whenever you change the Network Name of Server Name, @@SERVERNAME does not report such changes. @@SERVERNAME reports changes made to the local server name using the sp_addserver or sp_dropserver stored procedure.
To confirm do the following:
SELECT @@SERVERNAME
select SERVERPROPERTY('MACHINENAME')
If the two above outputs shown different name means do the following:
To make SELECT @@SERVERNAME reflect the new changed Network Name perform the below task.
USE master
GO
EXEC sp_dropserver 'OLDSERVERNAME'
GO
EXEC SP_addserver 'NEWNETWORKNAME','LOCAL'
GO
Once done please restart the SQL Services and then Query SELECT @@SERVERNAME.
The 'LOCAL' parameter fixed it for me. Thanks!
ReplyDeleteWhen I do the above, my select @@servername result still shows as NULL but when I add the
ReplyDeleteEXEC SP_addserver 'NEWNETWORKNAME','LOCAL'
GO
I get a message that my server already exists even after a restart! Why is this? This is a cloned sql server from a server to a VM so I'm wondering if that is why.
Hi, I have a problem... This command (sp_dropserver), send the msg:
ReplyDelete"Msg 15190, Level 16, State 1, Procedure sp_dropserver, Line 56
There are still remote logins or linked logins for the server 'SERVERNAME'"
How deleting this logins?
Thanks!
Mine still says Null as well, I tried:
Deletesp_addserver 'YourServer', 'Local', 'duplicate_ok'
Restarted all services
And still no difference.
Select CONVERT(char(20), SERVERPROPERTY('servername') returns the correct name though...
QUOTE
DeleteHi, I have a problem... This command (sp_dropserver), send the msg:
"Msg 15190, Level 16, State 1, Procedure sp_dropserver, Line 56
There are still remote logins or linked logins for the server 'SERVERNAME'"
How deleting this logins?
QUOTE
USE master
GO
EXEC sp_dropserver 'OLDSERVERNAME', droplogins
GO