我备份了一个数据库:

BACKUP DATABASE MyDatabase
TO DISK = 'MyDatabase.bak'
WITH INIT --overwrite existing

然后试图恢复它:

RESTORE DATABASE MyDatabase
   FROM DISK = 'MyDatabase.bak'
   WITH REPLACE --force restore over specified database

现在数据库处于还原状态。

有些人推测,这是因为备份中没有日志文件,需要使用以下方法前滚:

RESTORE DATABASE MyDatabase
WITH RECOVERY 

当然,这是行不通的:

Msg 4333, Level 16, State 1, Line 1
The database cannot be recovered because the log was not restored.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.

在灾难性的情况下,你想要的是一个无法工作的恢复。


备份包含数据文件和日志文件:

RESTORE FILELISTONLY 
FROM DISK = 'MyDatabase.bak'

Logical Name    PhysicalName
=============   ===============
MyDatabase    C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\MyDatabase.mdf
MyDatabase_log  C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\MyDatabase_log.LDF

当前回答

I had a similar issue with restoring using SQL Management Studio. I tried to restore a backup of the database to a new one with a different name. At first this failed and after fixing the new database's file names it was successfully performed - in any case the issue I'm describing re-occurred even if I got this right from the first time. So, after the restoration, the original database remained with a (Restoring...) next to its name. Considering the answers of the forum above (Bhusan's) I tried running in the query editor on the side the following:

RESTORE DATABASE "[NAME_OF_DATABASE_STUCK_IN_RESTORING_STATE]"

这解决了问题。一开始我遇到了麻烦,因为数据库名称包含特殊字符。我通过在周围添加双引号来解决这个问题-单引号将不起作用,给出“错误的语法接近……”错误。

这是我尝试解决这个问题(数据库处于恢复状态)的最小解决方案,我希望它可以应用到更多的情况。

其他回答

所有基于WITH RECOVERY的选项都不适合我。

所做的是做完整的恢复从管理工作室。

USE [master]
RESTORE DATABASE Sales_SSD
FROM  DISK = N'D:\databaseBackups02\Daily_Sales_20150309_0941.bak' 
WITH  FILE = 1,  
MOVE N'Sales_Data' TO N'C:\Data\SSD\Sales.mdf',  
MOVE N'Sales_Log' TO N'C:\Data\SSD\Sales_1.ldf',  
NOUNLOAD,  REPLACE,  STATS = 5

你试过运行验证吗?确保这是声音备份。

http://msdn.microsoft.com/en-us/library/ms188902.aspx

你可以这样做:

停止服务(MSSQLSERVER); 重命名或删除数据库和日志文件(C:\Program files \Microsoft SQL Server\MSSQL.1\MSSQL\Data…)或任何你有文件的地方; 启动服务(MSSQLSERVER); 删除有问题的数据库; 重新恢复数据库。

I had a similar issue with restoring using SQL Management Studio. I tried to restore a backup of the database to a new one with a different name. At first this failed and after fixing the new database's file names it was successfully performed - in any case the issue I'm describing re-occurred even if I got this right from the first time. So, after the restoration, the original database remained with a (Restoring...) next to its name. Considering the answers of the forum above (Bhusan's) I tried running in the query editor on the side the following:

RESTORE DATABASE "[NAME_OF_DATABASE_STUCK_IN_RESTORING_STATE]"

这解决了问题。一开始我遇到了麻烦,因为数据库名称包含特殊字符。我通过在周围添加双引号来解决这个问题-单引号将不起作用,给出“错误的语法接近……”错误。

这是我尝试解决这个问题(数据库处于恢复状态)的最小解决方案,我希望它可以应用到更多的情况。

在我的情况下,我只是右键单击数据库,然后任务—>恢复—>数据库—>Ok,一切都变得很好。