How Do I Change the Computer Name Stored in the SQL Server Database
Question
How Do I Change the Computer Name Stored in the SQL Server Database?
Certain database operations may fail if the computer name is changed.
Answer
To change the computer name from SERVER_OLD to SERVER_NEW, proceed as follows:
- Run the cmd.exe command to start the CLI of the Windows operating system and run the following script as the sa user or a user with the same permission as the sa user. The database login password is password.
osql -Usa -Ppassword select @@SERVERNAME go
The original computer name SERVER_OLD is displayed.
- Run the following commands to delete the original computer name SERVER_OLD and add the new computer name SERVER_NEW:
sp_dropserver @server='SERVER_OLD', @droplogins=NULL go sp_addserver @server='SERVER_NEW', @local='local', @duplicate_ok='duplicate_OK' go exit
- Restart the SQL Server service. For details, see How Do I Restart the SQL Server Service.