This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Knowledge Base
- :
- Conditionally run SQL scripts during uninstall
Subscribe
- Mark as New
- Mark as Read
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Conditionally run SQL scripts during uninstall
Conditionally run SQL scripts during uninstall
Summary
This article explains how to conditionally run SQL scripts during uninstall.Synopsis
The SQL Scripts are explicitly tied to component states. The condition that you are setting in the SQL view is actually the condition on the underlying component. Therefore, the condition does not affect during uninstall as Windows Installer removes all installed components regardless of their conditions. If you would like to conditionally run SQL scripts during uninstall, you need to add the conditional statement to your scripts.Discussion
The following instruction illustrates how to create a setup that will drop the 'MyDB' database during uninstall only when the SQL_SCRIPTS_DROPDB property is set to '1' .
1. Create a new Basic MSI project.
2. Navigate to SQL Scripts view.
3. Add a new connection and a SQL script.
4. Click the Runtime tab and check "Run Script During Uninstall" and uncheck "Run Script During Install".
5. Click the Script tab and add the following statements:
If ?%SQL_SCRIPTS_DROPDB%? = ?1?
BEGIN
DROP DATABASE [MyDB]
END
6. Click Text Replacement tab and add the following entry
Find What: %SQL_SCRIPTS_DROPDB%
Replace With: [SQL_SCRIPTS_DROPDB]
7. Build a project release.
No ratings