Renaming computer name does not update Sql Server meta data for @@SERVERNAME
- Posted by Sqltimes
- On October 20, 2013
- 0 Comments
We have a lot of virtual machines (VM’s) in our environment. Every day, the push is more and more to have database servers as VM’s as well. Our infrastructure team, when they create new VM’s, they use templates. From their perspective, it’s a lot easier when you have VM templates.
You need a new web server, sure clone from this web-server template and in a few minutes you have a brand new webserver running. They have templates for web-server, app-server, Oracle-DB-server, sql-server-vm, etc.
This results in a problem for us DBA’s.
When you install Sql Server software on a machine, it takes some properties of the Operating System and configures into its installation.
Example:
- New Windows groups are created. The Sql Server service account is added to one of these groups to assign necessary privileges.
- Sql Server default instance takes its name from machine name.
- …etc
This new VM they give us, still have configurations from the old VM. How do I change that?
This is how.
We’ll look at one such method:
1
2
3
4
|
sp_dropserver 'old_name' ; GO sp_addserver 'new_name' , local GO |
Restart the instance of SQL Server.
- For named instance, after computer name is changed.
1
2
3
4
|
sp_dropserver 'old_name\instancename' ; GO sp_addserver 'new_name\instancename' , local GO |
Hope this helps,Restart the instance of SQL Server.
0 Comments