How to: Manually Uninstall an Existing Instance of SQL Server

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

This topic describes how to manually uninstall a stand-alone instance of SQL Server. By following the steps in this topic, you also prepare the system so that you can reinstall SQL Server.

Important

To maintain or update an instance of SQL Server, you must be a local administrator with permission to log on as a service.

For information about how to uninstall a SQL Server failover cluster, see How to: Read a SQL Server Setup Log File or How to: Remove a Failover Clustered Instance (Setup). For information about how to manually uninstall an instance of SQL Server 2000, see How to: manually remove SQL Server 2000 default, named, or virtual instance.

Consider the following information before you uninstall SQL Server:

  • We recommend that you use Add or Remove Programs in Control Panel to uninstall SQL Server. However, if Add or Remove Programs does not completely uninstall the instance of SQL Server, you can follow the steps in this topic to manually uninstall the instance.
  • This article contains information about how to modify the registry. Make sure that you back up the registry before you modify it, and know how to restore the registry if a problem occurs. For more information about how to back up, restore, and modify the registry, see Description of the Microsoft Windows registry in the Microsoft knowledge base.
  • On a computer that is running SQL Server together with earlier SQL Server versions, Enterprise Manager and other programs that depend on SQL-DMO might be disabled. This can occur in the following situations:
    • Side-by-side installations of any combination of SQL Server 2008, SQL Server 2000, and SQL Server 7.0, where any one or more of these instances is uninstalled
    • Side-by-side installations of SQL Server 2000 with SQL Server 2008, where SQL Server 2000 is installed after SQL Server 2008
      This issue is caused by removal of the registration for the SQL Server SQL-DMO COM library. To re-enable Enterprise Manager and other programs that have SQL-DMO dependencies, register SQL-DMO by running regsvr32.exe sqldmo.dll at the command prompt. For more information, see Troubleshooting an Installation of SQL Server.
  • Before you remove SQL Server components from a computer that has the minimum required amount of physical memory, make sure that the page file size is sufficient. The page file size must be equal to two times the amount of physical memory. Insufficient virtual memory can cause an incomplete removal of SQL Server.
  • If you receive the following error message during SQL Server Setup, a SQL Server component was not uninstalled from the computer:
    A component that you have specified in the ADD_LOCAL property is already installed. To upgrade the existing component, refer to the template.ini and set the UPGRADE property to the name of the component.
  • In SQL Server 2005, the SQL Server Browser was an integrated installation together with the Database Engine or Analysis Services. In SQL Server 2008, the SQL Server Browser is a separate installation, performed automatically with the Database Engine or Analysis Services. If you have multiple instances of SQL Server 2008, the SQL Server Browser will uninstall automatically when the last instance of SQL Server 2008 is uninstalled.
    If SQL Server 2005 exists on the system with one or more instances of SQL Server 2008, the SQL Server 2008 Browser will not be removed automatically when the last instance of SQL Server 2008 is uninstalled. The SQL Server Browser that is installed with SQL Server 2008 will remain on the system to ease connections to the instance of SQL Server 2005. You can leave the SQL Server 2008 Browser installed with SQL Server 2005 and it will continue to function correctly.
    To uninstall all components of SQL Server 2008, you must uninstall the SQL Server Browser component manually from Add or Remove Programs. If you remove the SQL Server 2008 Browser when a SQL Server 2005 named instance is present, connectivity to SQL Server 2005 might be disrupted. In this situation, you can reinstall SQL Server Browser by repairing the instance of SQL Server 2005 from Add or Remove Programs, or by installing an instance of the SQL Server 2005 Database Engine or Analysis Services.

Before you remove SQL Server, follow these steps:

  • Back up your data. You might have databases that you want to save in their present state. You might also want to save changes that were made to the system databases. In either situation, make sure that you back up the data before you uninstall SQL Server. Alternatively, save a copy of all the data and log files in a folder other than the MSSQL folder. The MSSQL folder is deleted during uninstallation.
    The files that you must save include the following database files. These files are installed as part of SQL Server:

    • Distmdl.*
    • Master.*
    • Mastlog.*
    • Model.*
    • Modellog.*
    • Msdbdata.*
    • Msdblog.*
    • Mssqlsystemresource.*
    • Northwind.* (This database is an optional installation.)
    • Pubs.*
    • Pubs_log.*
    • Tempdb.*
    • Templog.*
    • ReportServer[$InstanceName] (This is the SSRS default database.)
    • ReportServer[$InstanceName]TempDB (This is the SSRS default temporary database.)
  • Delete the local security groups . Before you uninstall SQL Server, delete the local security groups for SQL Server components.

  • Save or rename Reporting Services folders. If you use the SQL Server installation together with Reporting Services, save or rename the following folders and subfolders:

    • <drive>\Microsoft SQL Server\Reporting Services

    • <drive>\Microsoft SQL Server\MSSQL\Reporting Services

    • <drive>\Microsoft SQL Server\<SQL Server instance name>\Reporting Services

    • <drive>\Microsoft SQL Server\100\Tools\Report Designer

      Note

      If you used the SSRS configuration tool to configure the installation, the names might differ from the names in this list. Additionally, the databases might be located on a remote computer that is running SQL Server.

  • Delete the SSRS virtual directories. Use Internet Information Services (IIS) Manager to delete the following virtual directories:

    • ReportServer[$InstanceName]
    • Reports[$InstanceName]
  • Delete the ReportServer application pool. Use IIS Manager to delete the ReportServer application pool.

  • Stop all SQL Server services. We recommend that you stop all SQL Server services before you uninstall SQL Server components. Active connections can prevent successful uninstallation.

  • Use an account that has the appropriate permissions. Log on to the server by using the SQL Server service account, or by using an account that has equivalent permissions. For example, you can log on to the server by using an account that is a member of the local Administrators group.

    Note

    You must perform the uninstallation steps listed here in the exact order given.

To manually uninstall an instance of SQL Server

  1. Make sure that the SQL Server Setup Support Files component is installed.

    In Add or Remove Programs, make sure that Microsoft SQL Server Setup Support Files appears in the list of installed programs. If Microsoft SQL Server Setup Support Files appears in the list, go to step 2.

    If Microsoft SQL Server Setup Support Files does not appear in the list, install this component before you continue. To do this, from the SQL Server installation media, double-click the Servers\setup\sqlsupport.msi file. In step 5 of this procedure, you will uninstall the Microsoft SQL Server Setup Support Files component.

  2. At the command prompt, run the following command to uninstall the SQL Server components:

    %ProgramFiles%\Microsoft SQL Server\100\Setup Bootstrap\ARPWrapper.exe /Remove
    

    Uninstall the SQL Server components one at a time until all the SQL Server components are uninstalled.

    Note

    Add or Remove Programs also runs the ARPWrapper.exe program by using the /Remove option. However, the reference to the ARPWrapper.exe program might have been deleted.

    If you receive one or more of the following error messages, see the "If you experience problems" section that follows this list:

    Registry Enumeration Failed

    If you have an instance of SQL Server that has more than one server component, such as the Database Engine and Analysis Services installed, setup will fail, and you receive the following error message:

    The setup has encountered an unexpected error in datastore. The action is RestoreSetupParams.

    This error is expected because of refcounting. A refcount is used to track how many programs use the same .dll file or the same .msi file. When a program is uninstalled, the program decrements the refcount for an .msi file by one. When the last program is uninstalled, the .msi file is deleted. In this case, the .msi file is the SQL Server Setup Support Files component (SqlSupport.msi). If you receive this error message, use one of the following methods to resolve the error:

    • Reinstall the SQL Server Setup Support Files component (SqlSupport.msi) before you uninstall each component in the instance.
    • Temporarily refcount the SqlSupport.msi file to itself. To do this, follow these steps:
    1. Obtain the GUID for the SQL Server Setup Support Files component. To obtain the GUID, follow steps 1 and 2 from the "If you experience problems" section.
    2. Use Registry Editor to create or to modify the following registry key with these values:
      Key Name: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\90\Bootstrap\MSIRefCount
      Value: Uninstall
      Type: REG_SZ
      Data: {11111111-1111-1111-1111-111111111111},{GUID}
      Note GUID is a placeholder for the GUID of the SQL Server support files. For example, the GUID of the English x86 SQL Server support files is as follows: Data: {11111111-1111-1111-1111-111111111111},{53F5C3EE-05ED-4830-994B-50B2F0D50FCE}

    If you experience problems

    If you experience problems when you try to uninstall the SQL Server components, follow these steps:

    • Start Registry Editor, and then locate the following registry key:
      HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

    • In the left pane, click each GUID. For each GUID that you click, look for a display name in the right pane that includes "Microsoft SQL Server." For example, look for the following names:

    • Microsoft SQL Server

    • Microsoft Analysis Services

    • Microsoft Reporting Services

    • Microsoft Integration Services

    • Microsoft SQL Server tools

    • Microsoft SQL Server Books Online
      When you see a display name that includes "Microsoft SQL Server," note the GUID that you clicked in the left pane.

    • For each GUID that you noted in the previous step, run the following command at the command prompt:

      start /wait msiexec /x {GUID} /l*v c:\sql_uninstall.log
      

    Notes:

    • In this command, replace GUID with the GUID that you noted in the previous step.
    • If you receive the following error message, contact product support.
      The setup has encountered an unexpected error in datastore. Please contact a Customer Support representative.

    For a complete list of product support telephone numbers and for information about support costs, see the support contact information Microsoft Web site.

    • Open the file at C:\Sql_uninstall.log. Approximately 15 lines from the bottom of the file, locate a line that resembles the following:
      MSI (s) (EC:F8) [12:52:18:007]: Product: Microsoft SQL Server Tools -- Removal completed successfully.

    If the uninstallation failed, note the component name and the GUID, and then save the Sql_uninstall.log file.

  3. Use Add or Remove Programs to uninstall the support components in the following order:

    • MSXML 6.0 Parser
    • SQLXML4
    • SQL Server VSS Writer
    • SQL Server Backward Compatibility
    • Anything else that is related to SQL Server, except for the SQL Server Native Client component and for the SQL Server Setup Support Files component.

    If the uninstallation fails for any one of the support components, you might receive the following error message:

    Setup failed due to missing prerequisites

    If you receive this error message, follow these steps:

    • Start Registry Editor, and then locate the following registry key:
      HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

    • In the left pane, click each GUID. For each GUID that you click, look for a display name in the right pane that matches the name of the redistributable file. When you see a display name that matches the name of the redistributable file, note the GUID that you clicked in the left pane.

    • For each GUID that you noted in the previous step, run the following command at a command prompt:

      start /wait msiexec /x {GUID} SKIPREDISTPREREQS=1 /l*v c:\sqlredist_uninstall.log
      

      In this command, replace GUID with the GUID that you noted in the previous step.

    • Open the file at C:\Sqlredist_uninstall.log. At the bottom of the file, locate a line that resembles the following line:
      MSI (s) (EC:F8) [12:52:18:007]: Product: Microsoft SQL Server Backward compatibility -- Removal completed successfully.
      If the uninstallation failed, note the component name and the GUID, and then save the Sqlredist_uninstall.log file.

  4. If all the other steps were successful, uninstall the SQL Server Native Client component by using Add or Remove Programs.

    Do not uninstall the SQL Server Native Client component if you have SQL Server components installed.

  5. If all the other steps were successful, uninstall the SQL Server Setup Support Files component by using Add or Remove Programs.

    If these steps did not uninstall all the components and all the files that are related to the instance of SQL Server, contact product support. For a complete list of product support telephone numbers, see the Microsoft Help and Support Web site.

See Also

Other Resources

How to: View SQL Server Setup Log Files
How to: Read a SQL Server Setup Log File

Help and Information

Getting SQL Server 2008 Assistance