Exclusive access could not be obtained because the database is in use_OFFLINE_ONLINE
Usually I used to get this type error while i am trying to RESTORE databases. So to avoid these type of errors permanently we need to write RESTORE command in between changing SINGLE_USER and MULTI USER statements. See below command.
Msg 3101, Level 16, State 1, Line 2
Exclusive access could not be obtained because the database is in use.
Msg 3013, Level 16, State 1, Line 2
RESTORE DATABASE is terminating abnormally.
Msg 3117, Level 16, State 1, Line 3
The log or differential backup cannot be restored because no files are ready to roll forward.
Msg 3013, Level 16, State 1, Line 3
RESTORE DATABASE is terminating abnormally.
Exclusive access could not be obtained because the database is in use.
Msg 3013, Level 16, State 1, Line 2
RESTORE DATABASE is terminating abnormally.
Msg 3117, Level 16, State 1, Line 3
The log or differential backup cannot be restored because no files are ready to roll forward.
Msg 3013, Level 16, State 1, Line 3
RESTORE DATABASE is terminating abnormally.
Don't use GO command between the below statement run it as a single script.
USE [master] ALTER DATABASE [Adventureworks] SET SINGLE_USER WITH ROLLBACK IMMEDIATE ---RestoreCommand between these two statements. RESTORE DATABASE Adventureworks FROM DISK = 'D:\Adventureworks_full.bak' WITH NORECOVERY ALTER DATABASE Adventureworks SET MULTI_USER
USE [master] ALTER DATABASE DatabaseNameHere SET SINGLE_USER WITH ROLLBACK IMMEDIATE ALTER DATABASE DatabaseNameHere SET OFFLINE
Comments