1 UseMaster2 GO3 --set two variables4 DECLARE @serverproperty_servername varchar( -), 5 @servername varchar( -)6 --gets the Windows NT server and instance information associated with the specified SQL server instance7 --you can read the Books Online "Serverproperty"8 SELECT @serverproperty_servername = CONVERT(varchar( -), SERVERPROPERTY ('ServerName'))9 --back to run microsoft® SQL server& #8482; The local server nameTen --you can see Books Online @ @SERVERNAME One SELECT @servername = CONVERT(varchar( -),@ @SERVERNAME) A - - Select @serverproperty_servername,@servername the --if @serverproperty_servername and @servername are different (because you changed your computer name), run the following - --Remove the wrong server name - EXECSp_dropserver@server=@serverproperty_servername--@[email protected] - --Add the correct server name + EXECsp_addserver@server=@servername,@local='Local' - + A sp_helpserver at -
Unified local server name and computer name