SQL Server: Database stuck in “Restoring” state

前端 未结 26 2070
后悔当初
后悔当初 2020-11-28 17:09

I backed up a database:

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

And then tried to restore it

26条回答
  •  萌比男神i
    2020-11-28 17:52

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

    This is of course only if you do not intend to restore any transaction log backups, i.e. you only wish to restore a database backup and then be able to access the database.

    Your command should look like this,

    RESTORE DATABASE MyDatabase
       FROM DISK = 'MyDatabase.bak'
       WITH REPLACE,RECOVERY
    

    You may have more sucess using the restore database wizard in SQL Server Management Studio. This way you can select the specific file locations, the overwrite option, and the WITH Recovery option.

提交回复
热议问题