/*============================================================================
  File:     FastFileInitialization.sql

  Summary:  This script shows the differences in file creation with and without
			fast file initialization.

  Date:     May 2005

  SQL Server Version: 9.00.1116 (IDW14)
------------------------------------------------------------------------------
  Copyright (C) 2005 Kimberly L. Tripp, SYSolutions, Inc.
  All rights reserved.

  For more scripts and sample code, check out 
    http://www.SQLskills.com

  This script is intended only as a supplement to demos and lectures
  given by Kimberly L. Tripp.  
  
  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.
============================================================================*/

------------------------------------------------------------------------------
-- Batch 1: Create a test database WITH zero initialization
------------------------------------------------------------------------------

DECLARE @StartTime	datetime
SELECT @StartTime = getdate()
CREATE DATABASE TestWithZeroInitialization
	ON PRIMARY 
	(NAME = N'TestWithZeroInitializationData', 
	FILENAME = N'C:\Program Files\Microsoft SQL Server\mssql.1\mssql\data\TestWithZeroInitializationData.MDF' , 
	SIZE = 2000,
	FILEGROWTH = 250,
	MAXSIZE = 3000)
LOG ON 
	(NAME = N'TestWithZeroInitializationLog', 
	FILENAME = N'C:\Program Files\Microsoft SQL Server\mssql.1\mssql\data\TestWithZeroInitializationLog.LDF' , 
	SIZE = 250, 
	FILEGROWTH = 50,
	MAXSIZE = 1000)
SELECT datediff(ms, @StartTime, getdate()) AS [TotalTIme With Zero Initilization]
go

------------------------------------------------------------------------------
-- END Step 1
-- Keep track of time here: XXXXX ms
------------------------------------------------------------------------------

-- Return to the lab exercise to complete the next few steps.


------------------------------------------------------------------------------
-- Reconnect Batch: Test Connection
------------------------------------------------------------------------------
select @@version
go

------------------------------------------------------------------------------
-- Batch 2: Create a test database WITHOUT zero initialization
------------------------------------------------------------------------------
DECLARE @StartTime	datetime
SELECT @StartTime = getdate()
CREATE DATABASE TestWithoutZeroInitialization
	ON PRIMARY 
	(NAME = N'TestWithoutZeroInitializationData', 
	FILENAME = N'C:\Program Files\Microsoft SQL Server\mssql.1\mssql\data\TestWithoutZeroInitializationData.MDF' , 
	SIZE = 2000,
	FILEGROWTH = 250,
	MAXSIZE = 3000)
LOG ON 
	(NAME = N'TestWithoutZeroInitializationLog', 
	FILENAME = N'C:\Program Files\Microsoft SQL Server\mssql.1\mssql\data\TestWithoutZeroInitializationLog.LDF' , 
	SIZE = 250, 
	FILEGROWTH = 50,
	MAXSIZE = 1000)
SELECT datediff(ms, @StartTime, getdate()) AS [TotalTIme Without Zero Initilization]
go
-- Keep track of time here: XXXXX ms


------------------------------------------------------------------------------
-- Optional Batch 3: Clean up the test databases to free up space
------------------------------------------------------------------------------
--DROP DATABASE TestWithZeroInitialization
--DROP DATABASE TestWithoutZeroInitialization