且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

还原数据库时出现问题.

更新时间:2021-08-05 10:24:49

以下应该有效:
仅当数据库没有任何连接时,才可以进行还原.在MS SQL Server上将所有用户踢掉的简单方法是:
Following should work:
A restore can only happen if the database does not have any connections to it. The easy way on a MS SQL Server to kick all users off is:
ALTER DATABASE [MyDB] SET Single_User WITH Rollback Immediate
GO


现在,您可以不受惩罚地执行还原.完成还原后,请确保将其设置回多用户模式:


Now, you can perform your restore with impunity. Make sure you set it back to Multi-user mode when you''re done with the restore:

ALTER DATABASE [MyDB] SET Multi_User
GO


此处引用完全相同的问题:专有由于正在使用数据库,因此无法获得访问权限 [ ^ ]


Referenced from exact same issue here: Exclusive access could not be obtained because the database is in use[^]




您是否检查过此博客:正在修复数据库正在使用错误从备份还原数据库时 [
Hi,

Have you checked this blog : Fixing database is in use error while restore database from backup[^]

You need to make your database offline before backup.