View Full Version : SQL Scripts to run only on first time install

02-25-2008, 11:28 AM
I have an InstallScript MSI project with some SQL scripts under the Server Configuration->Sql Scripts view.

Some of these scripts should only be called on the first install. I checked on these scripts the "Run Script During Install", but it gets also called on repair or update.

Is there any way to make them execute only on first install?

I tried to set a property OnFirstUIBefore:


and use it under "Specify a Conditional Statement", but this statement does not seem to be evalutated properly.

Any idea?

02-25-2008, 01:38 PM
the NOT INSTALLED = "TRUE" condition should work.

02-28-2008, 04:12 AM
Seems not to work. Whatever the condition evaluates to in the first install, it seems to keep that value on the maintenance installs.

I have the feeling, the conditions to run the SQL Scripts are not reevaluated during a maintenance/update install.

Is it possible to have the feature conditions reevaluated on maintenance?

02-28-2008, 09:08 AM
I tried several other methods, none seem to work.

I have an SQL script createDB.sql belonging to a feature "localDatabase". This script create the whole db schema with tables, users, stored procedures,.... I would like my InstallScript MSI project to call it only on the first install.

I inserted the script under Server Configuration/SQL Scripts. Under runtime, i tried several settings:

Checked "Run Script During Install" only -> script is called always, on first install, repair, change
Checked "Specify a Conditional Statement" only and set as condition: NOT INSTALLED -> script is never called
Checked "Specify a Conditional Statement" only and set as condition: (&localDatabase=3) AND NOT (!localDatabase=3) -> script is never called

Any other idea?

02-28-2008, 02:28 PM
Please try "NOT Installed" instead of "NOT INSTALLED". You may also need to set the Reevaluate Condition property to Yes for the associated component of your SQL script. See this thread (http://community.installshield.com/showthread.php?t=177978) for more information.

02-29-2008, 02:13 AM
I must do something wrong, I have tried "NOT Installed" but without success, the sql script is never called.

I have a feature "localDB":
- Install Level 500
- Condition to set installlevel to 1.
- the feature has two components: createDb.sql and dropDb.sql

Component createDb.sql_SQLComponent:
- Reevaluate Condition: YES

Component dropDb.sql_SQLComponent:
- Reevaluate Condition: YES

Server Configuration/SQL Scripts/createDb.sql:
- Runtime: checked only "Specify a Conditional Statement" and NOT Installed as condition

Server Configuration/SQL Scripts/dropDb.sql:
- Runtime: checked only "Run Script During Uninstall"

Why is createDb.sql not called on a first install? Did I miss something?

02-29-2008, 01:15 PM
You probably need to set the Install Level property of the feature below 100, and then elevate it above 100 using the Condition property if you do not want to install the feature for some conditions. I recommend that you check to see if the feature "localDB" is getting installed by generating a Windows Installer verbose log for the installation.

03-03-2008, 02:16 AM
I recommend that you check to see if the feature "localDB" is getting installed by generating a Windows Installer verbose log for the installation.

Could you explain a bit more, or point me to page explaining this?

How do I check if the feature is installed by generation a windows installer verbose log?

03-03-2008, 12:44 PM
You can generate a Windows Installer verbose log for your installation from the command line as follows:

setup.exe /v"/l*v c:\log.txt"

And search for the following entry in the log file:

Feature: localDB; Installed: Absent; Request: Local; Action: Local

Make sure that the Action state is Local.

05-28-2008, 01:21 AM
I am facing similar problem. tom36, can you please confirm if the solution suggested by hidenori helped to resolve your problem. For me it didn't.
Any other solutions?:mad:

Christopher Painter
05-28-2008, 03:38 PM
The property is Installed not INSTALLED.

Not Installed

BTW, I find it better to just do inline logic/error handling in your SQL and let the script run whenever the associated feature is being installed/reinstalled/uninstalled. This gives you more flexibility in servicing.