How to Completely Uninstall Microsoft SQL Server? / Windows / Windows Server / How to Completely Uninstall Microsoft SQL Server?

In this article, we’re going to look at a number of ways that you can uninstall a Microsoft SQL Server instance on a Windows computer. This article applies to all supported versions: Microsoft SQL Server 2019/2017/2014/2012.

It is recommended that you stop all SQL Server services before uninstalling SQL Server (SQL Server Configuration Manager -> SQL Server Services -> SQL Server -> Stop).

stop microsoft sql server instance

How to Manually Remove the MS SQL with SQL Installer (Setup.exe)?

To uninstall Microsoft SQL Server correctly, you can use the setup.exe installer from the source installation image. Mount the SQL installation ISO image and run a command prompt as an administrator. Use the following command to remove the default MSSQL instance and database engine:

  • Specify the list of SQL features to be removed in the /FEATURES option;
  • /INSTANCENAME – specify the name of the SQL Server instance that you want to remove.

Add the /q (or /QUIET) option to run the SQL Server uninstaller in silent mode.

Add /qs (/QUIETSIMPLE) if you want to see the SQL Server uninstall GUI, but not be able to cancel the installation or change settings. This mode also displays any SQL Server uninstall errors.

quiet uninstall ms sql server from cmd

You can open the SQL Server graphical removal wizard with the command


If there are multiple instances of MSSQL installed on the computer, the Remove SQL Server dialog box will appear and you will need to select the name of the MSSQLSERVER instance that you want to remove.

remove sql server 2019 instance

Next, you need to select the SQL components that you want to remove and click Next.

secet sql server features to remove

This method only removes features that are included in the SQL Server distribution. Additional components such as SQL Server Management Studio or Reporting Services must be uninstalled separately.

How to Uninstall SQL Server Using Windows Control Panel?

If you don’t have a SQL Server distro (installation image), you can remove SQL Server as a standard Windows application from the Control Panel. Go to Settings -> Apps & Features (or run ms-settings:appsfeatures) and find your version of Microsoft SQL Server in the list. Click the Uninstall button and then Remove.

uninstall microsoft sql server from windows control panel

Various errors may occur when uninstalling SQL Server:
Microsoft SQL Server 2019 Setup
The following error has occurred:
There is a problem with one of the Windows Installer package.
A program run as part of the setup didn’t finish as expected. Contact your support personnel or package vendor.

ms sql removal error: There is a problem with one of the Windows Installer package


There are validation errors on this page. Click OK to close this dialog box.
There are no valid SQL Server 2022 features to perform this operation.

There are no valid SQL Server 2022 features to perform this operation.

If you encounter errors when uninstalling SQL Server from the Control Panel, you can uninstall SQL Server components from the command line by their unique identifiers (GUIDs). For that, use the msiexec.exe tool with the /x option (described below).

Uninstalling SQL Server Using Command Line

You can use the built-in Windows Installer tool (msiexec) to remove programs. In order to remove any program installed through the Windows Installer, you need to run the following command:

msiexec /x {guid}

Here you must specify the application GUID. To obtain MS SQL Server application GUIDs on Windows, run the command:

wmic product get Name,IdentifyingNumber

wmic product get Name,IdentifyingNumber -0 list windows installer guids

There is a unique GUID for each component of the SQL Server. If you want to remove a specific SQL feature, locate it in the list, and then run the command:

msiexec /x {2C33F4D4-E9A5-4DE1-ACFE-3A13464E6703}

Confirm the removal of the SQL Server product feature.

msiexe uninstall SQL Server by GUID

In the same way, you will need to remove other components of SQL Server.

The following PowerShell script gets the GUIDs of all SQL Server components and removes them one by one.

$SQLVer = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall | Get-ItemProperty | Where-Object { $_.DisplayName -match "SQL Server " } | Select-Object -Property DisplayName, UninstallString
ForEach ($ver in $SQLVer) {
   If ($ver.UninstallString) {
       $uninst = $ver.UninstallString
       Start-Process cmd -ArgumentList "/c $uninst /quiet /norestart" -NoNewWindow

You must delete the SQL Server data and registry entries after you uninstall the SQL Server components.

Note. In my case, the C:\Program Files\Microsoft SQL Server folder size was over 100GB (mostly *.dmp files in the MSSQL15.MSSQLSERVER folder).delete MSSQL15.MSSQLSERVER directory

  1. Delete the SQL Server directories. You can delete them from Windows Explorer or using the commands:
    rmdir /S /Q "c:\Program Files\Microsoft SQL Server"
    rmdir /S /Q "c:\Program Files (x86)\Microsoft SQL Server"
    rmdir /S /Q "c:\ProgramData\Microsoft\Microsoft SQL Server"
    rmdir /S /Q "%userprofile%\AppData\Roaming\Microsoft\Microsoft SQL Server"
    rmdir /S /Q "%userprofile%\AppData\Local\Microsoft\Microsoft SQL Server"
  2. Open the Registry Editor and delete the following keys (if they exist):
    HKEY_LOCAL_MACHINE\Software\Microsoft\Microsoft SQL Server
    HKEY_CURRENT_USER\Software\Microsoft\Microsoft SQL Server
  3. Go to the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services key and remove all of the SQL Server services.
  4. Reboot Windows
One thought on “How to Completely Uninstall Microsoft SQL Server?”
  1. Unable to install SQL Server (setup.exe) Exit code (Decimal) -2064908287

Leave a Reply

Your email address will not be published. Required fields are marked *