Page 1 of 1

Check if DataBase exists or not

Posted: Thu Sep 05, 2013 2:38 pm
by Solnake
I have SQL script which creates database and DB objects. Installation creates new SQL Server instance if it needs and then run this script by "MS SQL Server" plug-in.
But I need to run this script one time only - if database doesn't exist. How it can do it?

Re: Check if DataBase exists or not

Posted: Fri Sep 06, 2013 9:25 am
by FrancescoT
Dear Solnake,

add an additional call to "MS SQL Server" plug-in, before the one that runs the MS SQL script.

Enter the name of database that you want test in the "Database" field, un-check the "Create Database If Absent " control and leave the script filed empty.

Then test the returned "MS SQL Server" plug-in value and conditionally execute your other "MS SQL Server" plug-in (the one that runs the script).
If the DB doesn't exist the plugin returns "CONNECT_DATABASE_ERROR".

Please have a look to IA documentation for more detailed info. (just press F1 in IA IDE).

Regards

Re: Check if DataBase exists or not

Posted: Fri Sep 06, 2013 10:30 am
by Solnake
It works. Thanks a lot :) Very simple solution. I spent 5 hours yesterday looking for how to do this.