View Full Version : Database in Use when trying to do RESTORE script

06-28-2006, 04:44 PM
I've made a connection to the SQL instance MMHX under SQL Scripts. It then runs a script that creates the database MMADMIN. I then have a script that does an SQL RESTORE DATABASE that restores a dat file into the database. The problem is when it gets to this in the install it says database in use and will not run the script. How do I disconnect the database, if that needs to be what happens.

06-29-2006, 02:36 AM
You need to have another connection that targets the 'master' database to run the script restoring the database in the SQL Scripts view. If you are using a Basic MSI project, you need to associate the Catalog Name with a different Windows Installer property for the second connection in the Advanced tab. By default, all connections share the same properties.

Hope this helps.

07-03-2006, 09:01 PM
Actually what was happening was if you put a Catalog Name in and check Create if Absent it will create the database and that is what made the database "in use". By clearing out catalog name and unchecking the box I can then run the CreateDatabase script and then the Restore one. Works fine.