2

I have a database showing up in SQL Enterprise Manager as "(Restoring...)"

If i do SP_WHO there is no restore process.

The disk and CPU activity on the server is very low

I think it is not restoring at all.

How can I get rid of this?

I've tried renaming the underlying MDF file, but even when I do "NET STOP MSSQLSERVER" it tells me the file is open.

I've tried using PROCEXP to find what process has the file open, but even the latest PROCEXP can't seem to do that on Windows Server 2003 R2 x64. The lower pane view is blank.

In the SQL Server log it says "the database is marked RESTORING and is in a state that does not allow recovery to be run"

Kara
  • 6,115
  • 16
  • 50
  • 57
rc1
  • 341
  • 3
  • 7
  • 17

3 Answers3

11

Sql Server has two backup types:

  • Full backup, contains the entire database
  • Transaction log backup, contains only the changes since the last full backup

When restoring, Sql Server asks you if you want to restore additional logs after the full backup. If you choose this option, called WITH NORECOVERY, the database will be left in Restoring state. It will be waiting for more transaction logs to be restored.

You can force it out of Restoring mode with:

RESTORE DATABASE <DATABASE_NAME> WITH RECOVERY

If this command gives an error, detach the database, remove the MDF files, and start the restore from scratch. If it keeps failing, your backup file might be corrupted.

Here's a screenshot of the restore options, with the default selected. The second option will leave the database in Restoring state.

Image of the restore options http://img193.imageshack.us/img193/8366/captureu.png

P.S.1. Are you running the 64 bit version of process explorer? Verify that you see procexp64.exe in the task manager.

P.S.2. This is more like a question for serverfault.

Andomar
  • 232,371
  • 49
  • 380
  • 404
0

WITH RECOVERY option is used by default when RESTORE DATABASE/RESTORE LOG commands is executed. If you're stuck in "restoring" process you can bring back a database to online state by executing:

RESTORE DATABASE YourDB WITH RECOVERY
GO

You can look for more options and some third party tools on this SO post https://stackoverflow.com/a/21192066/2808398

Community
  • 1
  • 1
Marko Krstic
  • 629
  • 6
  • 5
-1

If you are trying to get rid of the lock on the file I would recommend getting Unlocker http://www.emptyloop.com/unlocker/

It'll give you an option to unlock the file, or kill the process that has locked the file. Run this on the mdf and ldf files.

Another option is to try to Detach the files from Enterprise Manager or Sql Management Studio and then reattach the db. You can try this before running unlocker to see if sql server will just release the mdf and ldf files.

CAUTION: If you kill the process you might lose data or the data might get corrupted so use this only if you are trying to get rid of it and you have a good and tested backup.

KaraT
  • 124
  • 5
  • If you detach the database, you will not be able to reattach it again. A DB in a restoring state cannot be attached. Hence, if you detach it, you had better have a backup you can restore from – GilaMonster May 17 '09 at 12:26