The solution is as follows:
SELECT @ SERVERNAME
Use this command to check whether the user name has not been modified.
Then execute the following statement:
Copy codeThe Code is as follows:
EXEC sp_dropserver ''original server name''
EXEC sp_addserver
@ Server = ''current server name '',
@ Local = ''local''
After the execution is successful, run the command again: SELECT @ SERVERNAME. You can see that the value has not changed, or the original value. Don't worry. In this case, you only need to restart the SQL service.
Start-run-services. msc, open the service window, find SQL Server (MSSQLSERVER) to stop, and then start.
Note: The SQL Server (MSSQLSERVER) service is dependent on the SQL Server Agent (MSSQLSERVER). When the preceding service is disabled, the following services are also disabled, so do not forget it at startup.
OK. After the startup, SELECT @ SERVERNAME again. We can see that the value has changed to our current name. Try again and you can connect to it.
I use sql2005. Other versions do not know whether this method is feasible.