/*============================================================================
  File:     RegionalRangeCaseStudyFilegroups.sql

  MSDN Whitepaper: Partitioned Tables and Indexes in SQL Server 2005
  http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsql90/html/sql2k5partition.asp

  Summary:  This script was originally included with the Partitioned Tables 
			and Indexes Whitepaper released on MSDN and written by Kimberly
			L. Tripp. To get more details about this whitepaper please 
			access the whitepaper on MSDN.

			This script creates the filegroups needed to create the 
			partitioned table. For this script to succeed you must have
			created already a SalesDB database.
			
  Date:     January 2006

  SQL Server Version: 9.00.1399.06 (RTM)
------------------------------------------------------------------------------
  Copyright (C) 2005/2006 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.
============================================================================*/


-------------------------------------------------------
-- Add 5 FILEGROUPS to the Sales Database
-------------------------------------------------------
-- This script adds 5 FILEGROUPS and 5 FILES
-- (one file for each filegroup) to the SalesDB database. 
go

ALTER DATABASE SalesDB
ADD FILEGROUP [Spain]
GO

ALTER DATABASE SalesDB
ADD FILEGROUP [Italy]
GO

ALTER DATABASE SalesDB
ADD FILEGROUP [France]
GO

ALTER DATABASE SalesDB
ADD FILEGROUP [UK]
GO

ALTER DATABASE SalesDB
ADD FILEGROUP [Germany]
GO

ALTER DATABASE SalesDB 	
ADD FILE 	  
 	(NAME = N'SalesDBSpain',
        FILENAME = N'C:\SalesDB\SalesDBSpain.ndf',
  	SIZE = 1MB,
        MAXSIZE = 100MB,
        FILEGROWTH = 5MB) 
TO FILEGROUP [Spain]
go

ALTER DATABASE SalesDB 	
ADD FILE 	  
 	(NAME = N'SalesDBItaly',
        FILENAME = N'C:\SalesDB\SalesDBItaly.ndf',
  	SIZE = 1MB,
        MAXSIZE = 100MB,
        FILEGROWTH = 5MB) 
TO FILEGROUP [Italy]

ALTER DATABASE SalesDB 	
ADD FILE 	  
 	(NAME = N'SalesDBFrance',
        FILENAME = N'C:\SalesDB\SalesDBFrance.ndf',
  	SIZE = 1MB,
        MAXSIZE = 100MB,
        FILEGROWTH = 5MB) 
TO FILEGROUP [France]

ALTER DATABASE SalesDB 	
ADD FILE 	  
 	(NAME = N'SalesDBUK',
        FILENAME = N'C:\SalesDB\SalesDBUK.ndf',
  	SIZE = 1MB,
        MAXSIZE = 100MB,
        FILEGROWTH = 5MB) 
TO FILEGROUP [UK]

ALTER DATABASE SalesDB 	
ADD FILE 	  
 	(NAME = N'SalesDBGermany',
        FILENAME = N'C:\SalesDB\SalesDBGermany.ndf',
  	SIZE = 1MB,
        MAXSIZE = 100MB,
        FILEGROWTH = 5MB) 
TO FILEGROUP [Germany]

-------------------------------------------------------
-- Verify all files and filegroups
-------------------------------------------------------
USE SalesDB
go

sp_helpfilegroup
exec sp_helpfile
go
