Cannot restore MSSQL database

Using SQL Server 2008 R2 SQLEXPRESS (SQL Server 10.50.1600), I backed up a small database to file but when I tried to restore it, I got the following message even when logged I as sa and running the restore from the master database ?

should I detach the database prior to attempting a restore ?

Error message :

System.Data.SqlClient.SqlError : RESTORE cannot process database 'Midas1' because it is in use by this session.
It is recommended that the master database be used when performingthis operation.
Roger AlcindorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
you need to "disconnect" all sessions, including the "current one" (which is what the message is indicating), to that db.

in t-sql, you need to do
USE master

Open in new window

before your restore code
Roger AlcindorAuthor Commented:
I opened a query in the Midas database shown below and executed it

use master

I right-clicked on the master database to Tasks->Restore->Databse and ran the restore wizard with the same results ?

How do I connect to the master database  having disconnected all sessions ?
Guy Hengel [angelIII / a3]Billing EngineerCommented:
Start the activity monitor for the instance, check all the sessions to that db, and kill them
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

PadawanDBAOperational DBACommented:
There should be an option in the restore wizard to close all connections to the target database (enable that).  As an aside, all that option is doing is placing the target DB in single user mode and, from that same session, running the restore.
Roger AlcindorAuthor Commented:
Even killing all connections to the database (see attached screen shot) didn't work, I still got the same error. I had to detach the database (as mentioned I my original question) and then it restored  without any problem.
screen shot of activity monitor

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Roger AlcindorAuthor Commented:
The other comments did not resolve the issue whereas my suggestion did.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.