How to Force Remove Corrupted SQL Server 2008 R2 x64 Instance After Failed Uninstallation


4 views

When SQL Server 2008 R2 gets partially uninstalled, it leaves behind registry entries, service remnants, and stubborn files that refuse to disappear. I recently encountered this nightmare scenario where the standard uninstaller would complete successfully yet leave 700MB of files in Program Files\Microsoft SQL Server.

Here's the complete surgical procedure I developed after battling this for days:

REM First, stop any running SQL services
net stop MSSQLSERVER /y
net stop SQLSERVERAGENT /y
net stop MSSQLServerOLAPService /y

REM Delete services (admin cmd prompt)
sc delete MSSQLSERVER
sc delete SQLSERVERAGENT
sc delete MSSQLServerOLAPService

Create a cleanup.reg file with these contents (backup your registry first!):

Windows Registry Editor Version 5.00

[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer]
[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server]
[-HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MSSQLSERVER]
[-HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SQLSERVERAGENT]
[-HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MSSQLServerOLAPService]

After stopping services and cleaning the registry, manually delete these folders (adjust paths as needed):

  • C:\Program Files\Microsoft SQL Server\
  • C:\Program Files (x86)\Microsoft SQL Server\
  • C:\ProgramData\Microsoft\Microsoft SQL Server\
  • C:\Users\[YourUser]\AppData\Local\Microsoft\Microsoft SQL Server\

Microsoft's official Program Install and Uninstall Troubleshooter can sometimes clean up what manual methods miss. Run it with administrator privileges.

After completing all steps:

  1. Check Services MMC for any remaining SQL services
  2. Search registry for "MSSQL" or "SQLSERVER" remnants
  3. Verify all SQL-related folders are removed
  4. Attempt fresh installation to confirm clean slate

When SQL Server components are manually removed before running the proper uninstaller, it leaves the system in an inconsistent state. The Windows Installer database becomes corrupted, preventing standard uninstallation procedures from completing successfully. This manifests as:

  • Uninstaller completing without actual removal
  • Residual files in Program Files\Microsoft SQL Server
  • Registry entries remaining intact
  • Installation still appearing in Programs and Features

1. Terminate All SQL-Related Processes

@echo off
taskkill /F /IM sqlservr.exe
taskkill /F /IM SQLAGENT.EXE
taskkill /F /IM msftesql.exe
taskkill /F /IM sqlbrowser.exe
taskkill /F /IM sqlwriter.exe

2. Delete Installation Directories

Navigate to these locations and delete all contents:

rd /s /q "C:\Program Files\Microsoft SQL Server"
rd /s /q "C:\Program Files (x86)\Microsoft SQL Server"
rd /s /q "C:\ProgramData\Microsoft\Microsoft SQL Server"

3. Clean Up Registry Entries

Warning: Backup your registry before proceeding. Run regedit and delete these keys:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MSSQLSERVER
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SQLSERVERAGENT

For less technical users, Microsoft provides the Program Install and Uninstall Troubleshooter:

  1. Download from Microsoft Support site
  2. Select "Uninstalling" as the problem type
  3. Choose SQL Server 2008 R2 from the list
  4. Follow the wizard instructions

After completing all steps, verify removal by:

sc query | find "MSSQLSERVER"
wmic product get name | find "SQL Server"

Both commands should return empty results if uninstallation was successful.

For particularly resistant installations, use the Windows Installer CleanUp Utility:

msiexec /x {GUID-of-SQL-Server-package} /qn

To find the correct GUID:

reg query "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" /s | find "SQL Server"