This article will guide you how to completely uninstall SQL Server. Following the steps in this article, you will also need to prepare your system so you can reinstall SQL Server.
Attention: To uninstall an instance of SQL Server, you must be an administrator with logon as a service permission. To uninstall a SQL Server failover cluster, you need to use the Remove Node function included in SQL Server Setup to remove individual nodes.
Before uninstalling SQL Server, note the following important things:
- Before uninstalling SQL Server components from a computer with minimal physical memory, ensure that the page file size is sufficient. The page file size must be twice the physical memory capacity. Insufficient virtual memory can cause an incomplete uninstallation of SQL Server.
- If there are multiple versions of SQL Server, SQL Server Browser will automatically uninstall when the last version of SQL Server 2017 is uninstalled. If you want to uninstall all SQL Server 2017 components, you must uninstall the SQL Server Browser component manually from Programs and Features in Control Panel.
- When uninstalling SQL Server, the data file will be deleted tempdb was added during installation. Files have a name or part of a name tempdb_mssql_*. Ndf will be deleted if they exist in the system database directory.
Before uninstalling SQL Server
Step 1: Back up data
Although this is not a required step, many people want to back up the database in its current state or want to save changes that have been made in the system database. Therefore perform a data backup before uninstalling SQL Server. Also, save a copy of all data and log files in a folder, not in the MSSQL folder because this folder will be deleted during the uninstallation process.
The files you must save include the following database files:
- Master.mdf
- Mastlog.ldf
- Model.mdf
- Modellog.ldf
- Msdbdata.mdf
- Msdblog.ldf
- Mssqlsystemresource.mdf
- Mssqlsustemresource.ldf
- Tempdb.mdf
- Templog.ldf
- ReportServer [$Tên phiên bản]. This is Reporting Services' default database.
- ReportServer [$Tên phiên bản] TempDB. This is Reporting Services' default temporary database
Step 2: Delete security groups on the device.
Before uninstalling SQL Server, remove local security groups for SQL Server components.
Step 3: Stop all SQL Server services
You should stop all SQL Server services before removing SQL Server components. Having an active connection may prevent a successful uninstallation.
Step 4: Use an account with appropriate permissions.
Log in to the server by using the SQL Server service account or using an account with equivalent permissions. For example, you can log on to the server by using an account that is a member of the local Administrators group.
Uninstall an instance of SQL Server
Method 1: Uninstall SQL Server in Control Panel
Step 1. To start the uninstallation process, go to Control Panelthen select Programs and Features.
Step 2. Right click SQL Server and choose Uninstallthen click Remove. This will start the SQL Server Installation Wizard. Setup Support Rules run to verify computer configuration. To continue, click Next.
Step 3. On the page Select Instanceuse the drop-down box to specify an instance of SQL Server to remove, or specify options to remove only the SQL Server shared features and management tools. To continue, click Next.
Step 4. On the page Select Featuresspecifies features to remove for specific versions of SQL Server. The removal rules run to verify that the operation can complete successfully.
Step 5. On the page Ready to Removereview the list of components and features to be uninstalled, then click Remove to start the uninstallation.
Step 6. Even after uninstalling the last version of SQL Server, other programs associated with SQL Server will still show up in the list of programs in Programs and Features. However, if you close Programs and Features and open it next time, it will refresh the list of programs, showing only programs that are still installed.
Method 2: Uninstall SQL Server in regedit
If the above method fails, you can manually uninstall SQL Server with the steps below:
Step 1: Backup registry.
Step 2: Delete the following keys in regedit:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer
Step 3: Go to the following key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall and delete all sub keys related to SQL Server.
Step 4: Go to the following key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services and delete all keys related to SQL Server
Step 5: Delete all SQL Server folders in the computer C:\Program Files\Microsoft SQL Server and other subfolders.
If the uninstallation process fails, try to find the cause and fix the problem. In some cases, such as accidentally deleting important files, reinstalling the operating system is required before reinstalling SQL Server. However, if it still doesn't work, you can contact Microsoft Support for assistance.
See more: