SELECT @ @SERVERNAME, serverproperty (' SERVERNAME ')
--default instance
Use master
Go
--Set two variables
DECLARE @serverproperty_servername varchar (@servername), varchar (100)
--Obtains the Windows NT server and the instance information associated with the specified SQL server instance
SELECT @serverproperty_servername = CONVERT (varchar), serverproperty (' servername ')
--Returns the name of the local server running Microsoft SQL Server
SELECT @servername = CONVERT (varchar, @ @SERVERNAME)
--Displays the two parameters obtained
SELECT @serverproperty_servername, @servername
If @serverproperty_servername and @servername are different (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 '