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.