jjones
Posts: 68
Joined: Wed Jun 29, 2011 3:30 pm

Running a SQL script

I have a SQL script that needs to get run prior to the main installation kicking off because there is another custom action that depends on the tables being changed. It didn't appear that I could do this by just running the script via the SQL mechanism because you can't run a script, then do something else, then run the rest of them. To accomplish this, I created SQL query (even though I'm not returning data) and run the script via a Custom Action. The script appears to run (no errors) but no changes are made to the tables. If you run something as a query, are commands that alter the table ignored?

To work around this, I just run the SQL script via command line with sqlcmd.exe and that seems to work.
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Running a SQL script

Hello,

Advanced Installer SQL queries are meant to be used for binding Windows Installer properties to result set columns; they don't work properly with other types of SQL scripts (non SELECT statements).

Here's another workaround.
You can add a query and we further delete the DataBinding="RESULT_COLUMN_PROP" attribute from the .AIP(project file). In order to achieve that, you can open the .AIP(project file) in a text editor(e.g. notepad) and delete the DataBinding="RESULT_COLUMN_PROP" from the Query row of the SqlScriptComponent.

Save it and reopen the .AIP in Advanced Installer. You will see that your query is actually a SqlScript but you can still use the Query SQL database for data predefined custom action from the Custom Actions page and schedule it when you need it.

We need to do this because the Query SQL database for data predefined custom action only allows you to pick a SQL query.

Please let us know if that helped.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
jjones
Posts: 68
Joined: Wed Jun 29, 2011 3:30 pm

Re: Running a SQL script

Dan,

That absolutely helped! Thanks for the tip.

Jonathan
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Running a SQL script

You're welcome Jonathan,

If you have other questions, please let us know.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Aarthy
Posts: 2
Joined: Thu Jul 28, 2016 3:57 pm

Re: Running a SQL script

Hi,
I'm using a SQLScript to delete the store procedure and that doesn't seem to work using the the SQLQuery and above method you specified
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Running a SQL script

Hello,

Please accept my apologizes for the delayed reply.

I'm not sure I fully understand your setup project requirements. Can you please give us more details about the installation behavior you want to implement (maybe give us a small example)? Also, please send us the .AIP (project file) and a verbose log of the installation to support at advancedinstaller dot com so we can investigate them.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”