Have you ever finished a deployment and figured that you've used a wrong naming convention on Servers?

O.K. you're not the only one and you don't need to rebuild your servers just have them working fine.

At the Domain Controller

ADDS FQDN: MYDOMAIN.LOCAL

  1. netdom computername SRV-DC-01.MYDOMAIN.LOCAL /add:COMPANY-SRV-DC01.MYDOMAIN.LOCAL
  2. netdom computername SRV-DC-01.MYDOMAIN.LOCAL /makeprimary:COMPANY-SRV-DC01.MYDOMAIN.LOCAL
  3. shutdown  /r /t 0
  4. netdom computername COMPANY-SRV-DC01.MYDOMAIN.LOCAL /remove:SRV-DC-01.MYDOMAIN.LOCAL
  5. Dcdiag /v
  6. dcdiag /fix

At the SQL server

  1. netdom computername SRV-SQL-01.MYDOMAIN.LOCAL /add:COMPANY-SRV-SQL001.MYDOMAIN.LOCAL
  2. netdom computername SRV-SQL-01.MYDOMAIN.LOCAL /makeprimary:COMPANY-SRV-SQL001.MYDOMAIN.LOCAL
  3. shutdown  /r /t 0
  4. netdom computername COMPANY-SRV-SQL001.MYDOMAIN.LOCAL /remove:SRV-SQL-01.MYDOMAIN.LOCAL
  5. open SQL Server Management Studio and run the following query
For Default instance use the following:
exec sp_dropserver "SRV-SQL-01.MYDOMAIN.LOCAL"
Go
exec sp_addserver "COMPANY-SRV-SQL001.MYDOMAIN.LOCAL", local
Go
Select @@servername
 
For Named instance use the following:
exec sp_dropserver "SRV-SQL-01.MYDOMAIN.LOCAL\instancename"
Go
exec sp_addserver "COMPANY-SRV-SQL001.MYDOMAIN.LOCAL\instancename", local
Go

All domain-joined workstations working fine and all SQL server instances loading fine.

We can also create a test-sql.udl file on our SQL server desktop and give a try on it by accessing each SQL instance and its databases.

If our servers are running on Azure Resource Group we can also do the following:

  1. Select the target VM (take notes / screenshot of all VM information: subnet, vnet, ip address, size, etc. - we will need this info on step #5 below)
  2. Go to disks
  3. Detach all managed disks (take a screenshot with the disks order beforehand)
  4. Delete the VM *deleting the VM on Azure doesn't delete VM itself only its object*
  5. Wait for the task to be completed and click on the target VM OS disk and select Create VM and follow the wizard to create the "SAME VM" pointing the same previous VNET, subnet, IP address, NSG (network security group), Size and managed disks.
  6. Wait for the task to be completed and log on the VM