Error - Exclusive access could not be obtained because the database is in use. Msg 3101, Level 16, State 1, Line 3 Exclusive access could not be obtained because the database is in use. Msg 3013, Level 16, State 1, Line 3 RESTORE DATABASE is terminating abnormally.

We need to alter database and change to single user mode before restoring the DB and to avoid connection issues if application still connecting to DB we can include in restore command ,So it will automatically make DB to single user mode before restoring and it will change to multi user mode after restoring automatically

Use master
Go
Alter database set single_user with rollback immediate
Go
Restore database command
Go
Alter database set multi_user with rollback immediate
Go


Comments

Popular posts from this blog

How to read MSDTC Trace logs

CDC Monitoring