nam vo
nam vo

Reputation: 3457

Database is "restoring" after RESTORE

I try to restore a database from .bak file created by sql management studio 2012.

 RESTORE DATABASE db
   FROM DISK = 'd:\abc.bak'
   WITH NORECOVERY,
   MOVE 'abc' TO 'D:\My Data\db_Data.mdf', 
   MOVE 'abc_log' TO 'd:\My data\db_Log.ldf',
   REPLACE
GO

it went through but then cannot open the database, always has Restoring... status on the name.

What's going on here?

Upvotes: 1

Views: 521

Answers (2)

Vishal Suthar
Vishal Suthar

Reputation: 17194

You need to use the WITH RECOVERY option, with your database RESTORE command, to bring your database online from a recovery mode as part of the restore process.

You can also use the overwrite option WITH REPLACE

RESTORE DATABASE db
   FROM DISK = 'd:\abc.bak'
   WITH REPLACE, RECOVERY
   MOVE 'abc' TO 'D:\My Data\db_Data.mdf', 
   MOVE 'abc_log' TO 'd:\My data\db_Log.ldf'
GO

This is the most guaranteed way to restore a database.

Upvotes: 1

Andomar
Andomar

Reputation: 238296

The database remains in recovery, waiting for additional log restores. Use WITH RECOVERY to complete the restore.

Upvotes: 1

Related Questions