gogoWebsite

Sqlserver uses backup database file.bak to perform an error when restoring: Due to problems with the database, it cannot obtain exclusive access rights.

Updated to 2 days ago

Sqlserver  Use backup database file.bak to execute an error when restoring: exclusive access could not be obtained because the database is in issue. Right nowDue to problems with the database, exclusive access is not available. Restarting SQL server doesn't work

Solve this error I saw on the Internet that someone uses CSSDN

ALTER DATABASE [datebase] SET OFFLINE WITH ROLLBACK IMMEDIATE 

To solve the problem.

OFFLINEandONLINEIt is the transaction processing mechanism,The former is to disconnect other users from the database,后者是开启其他用户and数据库的连接,Meaning:Disconnect the databasegetReadsand immediately roll back all transactions

When restoring the database, you must execute it to disconnect the transaction from the database, otherwise an error will be reported.