SELECT @ SERVERNAME, SERVERPROPERTY ('servername ')
-- Default instance
USE master
GO
-- Set two variables
DECLARE @ serverproperty_servername varchar (100), @ servername varchar (100)
-- Obtain information about the Windows NT Server and the instance associated with the specified SQL Server instance
SELECT @ serverproperty_servername = CONVERT (varchar (100), SERVERPROPERTY ('servername '))
-- Returns the name of the local Server running Microsoft SQL Server.
SELECT @ servername = CONVERT (varchar (100), @ SERVERNAME)
-- Display the obtained Parameters
SELECT @ serverproperty_servername, @ servername
-- If @ serverproperty_servername is different from @ servername (because you changed the computer name), run the following
-- Delete the wrong server name
EXEC sp_dropserver @ server = @ servername
-- Add the correct server name
EXEC sp_addserver @ server = @ serverproperty_servername, @ local = 'local'