sp_dropserver '<ServerName>'
After the SQL Server restart, the @@SERVERNAME started returning NULL. You can confirm this; if the following query returns no records, the local server was deleted.
Select * From sys.servers Where server_id=0
Solution 1
Run the following query to add the server back.sp_addserver '<ServerName>',local
Solution 2
I would recommend you to useSelect ServerProperty('ServerName')
This approach returns the machine name, even if the sever name is not present in the sys.servers table.
No comments:
Post a Comment