Overview
The RESTORE ... WITH RECOVERY option puts the database into a useable state, so users can access a restored database.
Explanation
When you issue a RESTORE DATABASE or RESTORE LOG command the WITH RECOVERY option is used by default. This option does not need to be specified for this action to take place.
If you restore a "Full" backup the default setting it to RESTORE WITH RECOVERY, so after the database has been restored it can then be used by your end users.
If you are restoring a database using multiple backup files, you would use the WITH NORECOVERY option for each restore except the last.
If your database is still in the restoring state and you want to recover it without restoring additional backups you can issue a RESTORE DATABASE .. WITH RECOVERY to bring the database online for users to use.
T-SQL
Restore full backup WITH RECOVERYAs mentioned above this option is the default, but you can specify as follows.
Recover a database that is in the "restoring" stateThe following command will take a database that is in the "restoring" state and make it available for end users.
Restore multiple backups using WITH RECOVERY for last backupThe first restore uses the NORECOVERY option so additional restores can be done. The second command restores the transaction log and then brings the database online for end user use.
SQL Server Management Studio
When restoring using SSMS the WITH RECOVERY option is used by default, so there is nothing that needs to be set but this can be set or changed on the options page when restoring.
No comments:
Post a Comment