If you get the error:
Exclusive access could not be obtained because the database is in use:
It is because when you restore the a database you should have Exclusive lock, you can kill the process which are using database. otherwise use the command showed below.
-- -- This should give you Exculusive lock -- USE MASTER
ALTER DATABASE MyDatabase SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
-- Do your work
-- Reenable the database ALTER DATABASE MyDatabaseSET MULTI_USER WITH ROLLBACK IMMEDIATE; -- --
No comments:
Post a Comment