gpt4 book ai didi

sql-server - 恢复备份时,如何断开所有事件连接?

转载 作者:行者123 更新时间:2023-12-01 16:32:54 29 4
gpt4 key购买 nike

由于事件连接,My SQL Server 2005 无法恢复备份。我怎样才能强制它?

最佳答案

您想要将数据库设置为单用户模式,进行恢复,然后将其设置回多用户模式:

ALTER DATABASE YourDB
SET SINGLE_USER WITH
ROLLBACK AFTER 60 --this will give your current connections 60 seconds to complete

--Do Actual Restore
RESTORE DATABASE YourDB
FROM DISK = 'D:\BackUp\YourBaackUpFile.bak'
WITH MOVE 'YourMDFLogicalName' TO 'D:\Data\YourMDFFile.mdf',
MOVE 'YourLDFLogicalName' TO 'D:\Data\YourLDFFile.ldf'

/*If there is no error in statement before database will be in multiuser
mode. If error occurs please execute following command it will convert
database in multi user.*/
ALTER DATABASE YourDB SET MULTI_USER
GO

引用:Pinal Dave ( http://blog.SQLAuthority.com )

官方引用:https://msdn.microsoft.com/en-us/library/ms345598.aspx

关于sql-server - 恢复备份时,如何断开所有事件连接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1154200/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com