Sql-server – How to restore a transaction log

restoresql servertransaction-log

Could you tell me the reason why it is mandatory to restore the full backup with NORECOVERY option before restoring the transaction log? otherwise Transaction log is always grayed (Task -> restore -> Transaction log)

Thanks a lot in advanced

Best Answer

If you perform a full RESTORE WITH RECOVERY, that means you want to only restore the full backup and immediately bring the database online.

When you perform a full RESTORE and want to also restore differential or transaction log backups as well, then you want to RESTORE WITH NORECOVERY so that the database does not come online and additional restores are possible.

You can use T-SQL to perform both at the same time (copied from BOL): Restore Transaction Log Backup

RESTORE DATABASE AdventureWorks2012
   FROM AdventureWorks2012_1
   WITH NORECOVERY;
GO
RESTORE LOG AdventureWorks2012
   FROM AdventureWorks2012_log
   WITH FILE = 1,
   NORECOVERY;
GO
RESTORE LOG AdventureWorks2012
   FROM AdventureWorks2012_log
   WITH FILE = 2,
   NORECOVERY;
GO
RESTORE LOG AdventureWorks2012
   FROM AdventureWorks2012_log
   WITH FILE = 3,
   NORECOVERY;
GO
RESTORE DATABASE AdventureWorks2012
   WITH RECOVERY;
GO