cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
selwynreynolds
Level 7

SQL Database Already Exists

I have an InstallScript MSI project. In the SQL Scripts view I ran two scripts. 1 to create a database and 1 to add tables to the database. The install works fine the first time it is run. IF the install is run on a machine that already has the database on it then an error occurs and the install runs. What I need to do is only run the database scripts if the database does not exist. Is there a way in the InstallScript MSI project that I can check for that? Thank you.
Labels (1)
0 Kudos
(2) Replies
Christopher_Pai
Level 16

You have to do the check yourself in your SQL file. Basically something like:

if not exists(select * from sys.databases where name = 'Testing')
create database testing
0 Kudos
selwynreynolds
Level 7

Thank you. I had thought to do it that way but wondered if IS would do it for me. 🙂
0 Kudos