What is the relation between renaming the computer and sp_dropserver/sp_addserver?
-
I have default SQL server instance (not a named instance).
have changed the SQL server computer name, and not run the following commands:
sp_dropserver 'oldname'; sp_addserver 'newname', 'local'
; restart - then what is the impact of not running these?Either ways (whether the above commands are run or not run), all applications that use the old computer name fail and need to use the new computer name.
-
Host name re-naming will not automatically take effect
sys.servers
system table where the instance name is recorded. The https://docs.microsoft.com/en-us/sql/database-engine/install-windows/rename-a-computer-that-hosts-a-stand-alone-instance-of-sql-server?view=sql-server-ver15 needs to be performed to make the hostname changes to reflect insys.servers
metadata table.Update system metadata to reflect computer name changes for remote connections and applications that use @@SERVERNAME, or that query the server name from sys.servers.
To make the application changes easy, we create CName(DNS record) which is mapped to the hostname/AGName. And applications should use the CName in their connection strings instead of direct host name or AG name. So whenever there is a change to host or AG name, all you need to do is update the DNS mapping, so the applications will automatically redirected to use the new changes.
Ex: your cahanges will look like this before and after host name is updated.
Before:
applicationName Record Type Destination application01.domain.com CNAME hostname01
After: (hostname01 is updated to hostname02)
applicationName Record Type Destination application01.domain.com CNAME hostname02
Your applications must use
application01.domain.com
in their connection string.Read more about CName usage https://support.dnsimple.com/articles/cname-record/ .