Deleting a SQL Server Database During Uninstallation

InstallShield 2020

Project:This information applies to the following project types:

Basic MSI
DIM
InstallScript
InstallScript MSI

Note:You cannot delete a database to which you are currently connected.

If you need to remove a SQL database during uninstallation, you can do so through your SQL script. The following procedure demonstrates how to configure your project and SQL script to delete a Microsoft SQL Server database.

To remove a Microsoft SQL Server database during uninstallation:

1. In the View List under Server Configuration, click SQL Scripts.
2. Add a SQL connection.
3. On the General tab, in the Catalog Name box, type Master.

Master is the name of the system database that exists on all Microsoft SQL Server systems; since you cannot delete a database to which you are currently connected, you can connect to the Master database and then delete a different database to which you are not connected.

4. Enter the authentication information for the server.
5. Add a new SQL script file.
6. Add the following to the SQL script file:

DROP DATABASE DatabaseName

GO

DatabaseName is the name of the database that you want to delete.

Tip:As an alternative to the aforementioned procedure, you can perform the same operation completely in SQL script. To do so, enter the following code in your SQL script:

USE Master

DROP DATABASE DatabaseName

GO

DatabaseName is the name of the database that you want to delete.