snippetsqlMajor
How to Delete Restoring Database
Viewed 0 times
restoringdatabasedeletehow
Problem
I am running log shipping with SQL server 2008 R2.
I have a situation where the secondary database drive ran out of space and was not applying log shipping transaction logs.
The way I want to fix this is delete the databases at the secondary and configure log shipping from scratch.
The problem I have now is that my secondary databases are in the restoring state, and I cannot delete them. How can I proceed?
For instance if I try to take them offline I get the error,
I have a situation where the secondary database drive ran out of space and was not applying log shipping transaction logs.
The way I want to fix this is delete the databases at the secondary and configure log shipping from scratch.
The problem I have now is that my secondary databases are in the restoring state, and I cannot delete them. How can I proceed?
For instance if I try to take them offline I get the error,
ALTER DATABASE is not permitted while the database is in the Restoring state.Solution
RESTORE DATABASE dbname
FROM DISK = 'dbname .bak'
WITH REPLACE, RECOVERY --force restoreor just
RESTORE DATABASE dbname WITH RECOVERYthe
REPLACE Overwrite the existing database, do it only if you are sure you want to override your existing database as you mentioned you dont care to delete itRESTORE WITH RECOVERY is the default behavior which leaves the database ready for use by rolling back the uncommitted transactions. Additional transaction logs cannot be restored.
That should bring the database online. Then you can delete it & try again.
Code Snippets
RESTORE DATABASE dbname
FROM DISK = 'dbname .bak'
WITH REPLACE, RECOVERY --force restoreRESTORE DATABASE dbname WITH RECOVERYContext
StackExchange Database Administrators Q#19155, answer score: 26
Revisions (0)
No revisions yet.