restore to a different DB name

  • I need to "refresh" a training DB with a backup from a live DB.  The restore is from a full backup and I have it set to overwrite the existing DB using MOVE.  The failure message is :

    "RESTORE cannot process the database because it in use by this session.  It is recommended that the master database be used when performing this operation." 

    I have killed the process for my target DB prior to running the restore scipt, but still get the error.  How do I run the restore from the master? 

  • Could you post the SQL you are using to restore the database?

  • I just figured it out after the initial posting.  I just had to get out of  SQL Server Management Studio and run the scripts independently - which opens it back up again but without attaching to a database.  Hence the "run from master" message.

    Thanks for trying to help though.

  • The message was telling you that you were trying to run the restore operation while you were in the database.  If you have enterprise manager (or query analyzer for that matter) connected to the database you want to restore, the restore operation cannot take the database offline to perform the operation.

  • For the record: You can't connect to a database server without connecting to a database.  When you closed SSMS then opened it again, you connected to database set up as your default prerefence on your user account.  That's probably "Master", which is a good one to use because it is guaranteed to exist on any server.  (If you changed your default, to say "Northwind", and then Northwind goes offline, you'd have to change your connection details before you could connect to the server!)

    So rather than shut down SSMS before running your restore script, just put

    USE MASTER;

    at the top.

  • Thanks. Good to know. It's also in a fail-over cluster environment that took a try or two to figure out that I needed to be logged on to the active server and not the cluster.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply