gpt4 book ai didi

c# - 数据库 "DBName"的日志尾部尚未备份

转载 作者:IT王子 更新时间:2023-10-29 03:57:55 25 4
gpt4 key购买 nike

我尝试使用以下查询恢复数据库:

ALTER DATABASE [DatabaseName] SET Single_User WITH Rollback Immediate GO
RESTORE DATABASE DatabaseName FROM DISK = 'C:\DBName-Full Database Backup'
ALTER DATABASE [DatabaseName] SET Multi_User GO

但我没有恢复数据库,而是收到此错误:

Msg 3159, Level 16, State 1, Line 2

The tail of the log for the database "DatabaseName" has not been backed up. Use BACKUP LOG WITH NORECOVERY to backup the log if it contains work you do not want to lose. Use the WITH REPLACE or WITH STOPAT clause of the RESTORE statement to just overwrite the contents of the log. Msg 3013, Level 16, State 1, Line 2 RESTORE DATABASE is terminating abnormally.

最佳答案

如果您不关心现有数据库或日志,您收到的错误消息会准确告诉您需要做什么。

RESTORE DATABASE DAtabaseName FROM DISK = 'C:\DBName-Full Database Backup' 
WITH REPLACE

在 SQL Server Management Studio(任务 > 恢复)中,您可以通过打开左侧的“选项”页面并勾选“覆盖现有数据库”来添加 WITH REPLACE 选项。

关于c# - 数据库 "DBName"的日志尾部尚未备份,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12370944/

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