Labels

Thursday, 17 December 2015

Restore in SQL Server


Restore:

              Restore means recover the data from backups.

Common Scenarios to restore the database

       1. To restore the lost and corrupted data after a system failure .
       2. To restore a database onto a development system for user by application developers while developing and testing new code .
       3. To restore a database onto test system to load test applications and database features.
       4. To restore a database on separate server as a read - only database to perform queries for reports.


  There are 3 recovery states for Restore .

                                          1. With Recovery
                                          2. With No -Recovery
                                          3. Standby

1. With Recovery :
       
With recovery option the database will comes to online and get ready to  using database .
But Further backups cannot be restored .
Generally while restoring recent / last T.Log backup we can choose this        option .

 Syntax :

  Restore database database name from disk ="path" with recovery

2. With No -Recovery :

With No-Recovery option the database will comes to restoring mode and    further backups can restore .
But users can't access the database .
Generally use this option for all backups (except recent log ) for restore further backups.

 Syntax :

  Restore database database name from disk ="path" with no recovery


3. Standby :
With stand by option the database will comes to Restoring / Read - Only mode .
In this mode further backups can restore but users have read - only access to database.
Generally use this option for all backups (except recent log ) for restore further backups.

Syntax :

  Restore database database name from disk ="path" with no standby


Restore Strategy :

                1. First restore recent last full backup .
                2. Then restore last diff.backup .
                3. Then restore all transaction log backups since last recent             full  / diff backups .

Point - in - time restore :

     Point-in-time restore is used to restore a database to a particular time just before a failure has occurred or before corrupt data .

STOPAT option is used to restore a database to specific time .

Note: online restore is possible only in enterprise edition .

No comments:

Post a Comment