Check if DataBase exists or not

Got a problem you cannot solve? Try here.
Post Reply
Solnake
Posts: 4
Joined: Thu Sep 05, 2013 2:32 pm

Check if DataBase exists or not

Post 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?
FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: Check if DataBase exists or not

Post 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
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
Solnake
Posts: 4
Joined: Thu Sep 05, 2013 2:32 pm

Re: Check if DataBase exists or not

Post by Solnake »

It works. Thanks a lot :) Very simple solution. I spent 5 hours yesterday looking for how to do this.
Post Reply