cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Joseph_Schrag
Level 6

How Do I prevent SQL script from running on Uninstall?

I have a Basic MSI Installer that runs a sql script to create a database. In the original version I also had a sql script that ran on uninstall to drop the database.

Currently I am creating an major upgrade and I have realized that this will perform an uninstall of the old version. The problem, of course, is that the database will be dropped and recreated as part of the upgrade. How do I prevent this from happening?
Labels (1)
0 Kudos
(6) Replies
abby27
Level 4

Hello Joseph
Did you find a solution to the issue?
I ma struggling with a similar issue and haven't found a solution yet.
Please let me know if you did.
Thanks
0 Kudos
Joseph_Schrag
Level 6

I ended up having to leave the script in place for one upgrade, but render it harmless. So, I created a major upgrade that does not run an uninstall before continuing (see attached screenshot). Then went to the sql script and unchecked the "Run script during uninstall" checkbox (Runtime tab). And, just for good measure, I changed the text of the script to something harmless like "select 1".

This will leave the script on the machine, but render it harmless. So, the next time you create an upgrade, you can let it uninstall (the better option IMO). However, it will no longer run the script on uninstall.

At this point you can safely remove the sql script from the install altogether.

In my case, I needed this result immediately, so I had to send my guys out with two upgrades. One to render the script harmless, and one to do some actual upgrades. It was less than ideal, but did the job in a pinch.
0 Kudos
abby27
Level 4

Joseph,
Thanks for sharing your solution.
One question: My old product 1.0.123 has been deployed at several client locations. Now i am doing a major upgrade 2.0.98.
When the user runs the setup for 2.0.98, it first uninstalls the old version 1.0.123.
My question is, whether the uninstall sequence/actions in the 1.0.123 are executed or the ones in 2.0.98 ?

Is there a better way you know of that could retain the SQL Server data/database when doing a major upgrade?
thnx
0 Kudos
Joseph_Schrag
Level 6

To avoid an uninstall on a major upgrade, you must choose the "Install Setup then remove unneeded files" option as shown in the screenshot on my previous post. That will leave you with 2.0.98 without explicitly uninstalling 1.0.123. Basically, you are overwriting everything. After that, an uninstall will run the 2.0.98 uninstall (1.0.123 no longer exists on that machine).

That said, I hope you plan on thoroughly testing your upgrade package to test these statements.

Unfortunately, I do not have a better way. I was forced to take this route because of time constraints.
0 Kudos
abby27
Level 4

Joseph,
Thanks for the solution. Your solution works as required with a few minor tweaks, because the product was not being completely uninstalled if i chose the 2nd option ie) "Install Setup then remove unneeded files" .

Anyway, for the database uninstall to not run during a Major Upgrade, your solution works !!
Thnx
0 Kudos
Joseph_Schrag
Level 6

Glad I could help 🙂 .
0 Kudos