/*============================================================================
  File:     6_Restore_TailLog.sql

  Summary:  This script shows how to restore a tail-log backup
			for a database.

  Date:     April 2017

  SQL Server Version: 2005/2008/2008R2/2012/2014/2016
------------------------------------------------------------------------------
  Written by Erin Stellato, SQLskills.com

  For more scripts and other useful content, go to:
	http://www.SQLskills.com

  This script is intended only as a supplement to demos and lectures
  given by Erin Stellato.  
  
  THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF 
  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 
  TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  PARTICULAR PURPOSE.
============================================================================*/

USE [master];
GO
RESTORE DATABASE [AdventureWorks2016] 
	FROM  DISK = N'C:\Backups\AW2016_BaseFull.bak' 
	WITH  FILE = 1,  
	NORECOVERY, 
	REPLACE,
	STATS = 5;
GO

RESTORE LOG [AdventureWorks2016] 
	FROM  DISK = N'C:\Backups\AW2016_TLog1.trn' 
	WITH  FILE = 1,  
	NORECOVERY,  
	STATS = 5;
GO

RESTORE LOG [AdventureWorks2016] 
	FROM  DISK = N'C:\Backups\AW2016_TLog2.trn' 
	WITH  FILE = 1,  
	NORECOVERY,  
	STATS = 5;
GO

RESTORE LOG [AdventureWorks2016] 
	FROM  DISK = N'C:\Backups\AW2016_TLog3.trn' 
	WITH  FILE = 1,  
	NORECOVERY,  
	STATS = 5;
GO

RESTORE LOG [AdventureWorks2016] 
	FROM  DISK = N'C:\Backups\AW2016_TLog4.trn' 
	WITH  FILE = 1,  
	NORECOVERY,  
	STATS = 5;
GO

RESTORE LOG [AdventureWorks2016] 
	FROM  DISK = N'C:\Backups\AW2016_TailLog.trn' 
	WITH  FILE = 1,  
	NORECOVERY,
	STATS = 5;
GO


RESTORE DATABASE [AdventureWorks2016]
	WITH RECOVERY;
GO

USE [AdventureWorks2016];
GO

SELECT [FirstName], [LastName]
FROM [Person].[Person]
WHERE [FirstName] = 'Bruce';
GO

SELECT [FirstName], [MiddleName], [LastName]
FROM [Person].[Person]
WHERE [FirstName] = 'Logan';
GO
