The following is a T-SQL script you can use to rename your SQL Server after you have changed the computer name. This script will work if you are connected to the default instance or a named instance. After running the script, you must restart SQL Server for the action to complete.
DECLARE @machinename sysname, @servername sysname, @instancename sysname
SELECT @instancename =
       CASEÂ
           WHEN charindex(‘\’, @@servername) = 0 THEN ”Â
           ELSE SUBSTRING(@@servername,Â
               CHARINDEX(‘\’, @@servername), (len(@@servername)+ 1) -Â
                CHARINDEX(‘\’, @@servername))Â
            END
SET @machinename = convert(nvarchar(100), serverproperty(‘machinename’)) + @instancename;
EXEC sp_dropserver @@servername;
EXEC sp_addserver @machinename, ‘local’


















