I am trying to restore a database in my sql server 2005 express edition. I know that to restore the database I need to make it to single user. I am giving this command to make it to single user
use [master] alter database database_name set single_user with rollback immediate
This command executed properly and I can even see a small image in the object explorer on this database showing that this is now single user.
Now I am trying to restore the database, by following these steps ->right click on the database and tasks and then to restore database. I am selecting the path where the backup file is located and clicking on restore.
But I still get that error "Exclusive access could not be obtained because database is in use(microsoft.sqlserver.smo). Am I missing anything. I have googled it and all most all the sites suggest that database needs to be in single user mode and nothing else.
I did not try the detach and attaching of database method. I have never done that before and would like to know if that is safe to do.
edit: thanks for the answers. Both suggested me same answer so I am marking one answer as chosen.
I even selected overwrite the existing database from options.