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

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

  Date:     April 2018

  SQL Server Version: 2005/2008/2008R2/2012/2014/2016/2017
------------------------------------------------------------------------------
  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 [AdventureWorks2017] 
	FROM  DISK = N'C:\Backups\AW2017_BaseFull.bak' 
	WITH  FILE = 1,  
	NORECOVERY, 
	REPLACE,
	STATS = 5;
GO

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

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

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

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

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


RESTORE DATABASE [AdventureWorks2017]
	WITH RECOVERY;
GO

USE [AdventureWorks2017];
GO

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

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