Every once in awhile you run into an issue where a program just doesn’t want to uninstall. Ran into this scenario with MSSQL Server 2008 R2. Following the normal Programs and Features uninstall in Control Panel I received the message of failed to uninstall.
This process requires removing directories, services and registry entries. As with anytime the registry is involved you will want to back up the registry.
Remove SQL Server Services
First remove any SQL services using sc delete <service> command. To get the name of the service double click on it in services.msc and find the name used for ServiceName or use sc command from the command prompt.
C:\> sc query | find /I “sql”
Now that we have the service name, let’s stop them and remove them from existence.
Open a command prompt and type
C:\> net stop <servicename>
C:\> sc delete <servicename>
Do this for all the services. Found for SQL server.
Delete Microsoft SQL Server Directories
Delete the following directories.
- C:\Program Files (x86)\Microsoft SQL Server
- C:\Program Files\Microsoft SQL Server
- C:\Program Files (x86)\Common Files\microsoft shared\SQL Debugging
- C:\Program Files\Common Files\Microsoft Shared\SQL Debugging
It is possible there could be files and use and you will need to reboot and then retry the deletion after the reboot.
Delete Registry Entries
**Note: Backup the registry before deleting any entries. You can render the server unusable with an incorrect deletion.
With that stated let’s move ahead. Open regedt32 and navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall. Expand the key and click on each entry and delete any key that has SQL server in it and or matches
At this point you should be able to reinstall MSSQL Server 2008 R2 on your server.