Exclusive access could not be obtained because the database is in useThis error normally discourages because we wonder what exclusive access is this that we need to successfully restore the database. After searching a while you come to conclusion that the database to which we are restoring our backup is in use by one or some users you have already added. The popular solution is - temporarily isolate the user from the database Easy, if you run this command at your server:
Use master go Alter Database mydbname SET SINGLE_USER With ROLLBACK IMMEDIATE RESTORE DATABASE mydbname FROM DISK = 'C:\abc.bak'Now you are right if you suspect whether we should the roll back to multi user. Yes this way:
Use master; go ALTER DATABASE mydbname SET MULTI_USER; goNote that we run the commands against the master database, not the candidate database itself. And did I do the same last time? Nope. I was just happening with a slight mistake. I had created users for the db before I restored the database. So to save yourself from all those stuffs explained above, just create the database in the server, restore your backup file to it and only then create the database users. Done! Thanks.