A SQLServerCurry viewer contacted me to find out if there was an easy way to create partition tables on the AdventureWorks database. He wanted to study it for educational purposes.
For all those who are looking out for an existing partition script to partition tables of the AdventureWorks database, follow these steps:
Go to http://www.codeplex.com/MSFTScrptProdSamples and download the ‘PartitionScript’ of the SQL Server database version you have installed. I have SQL Server 2008 and I have downloaded the script from here (SQL2008.Data_Engine_Admin_Script.Samples.x86.msi)
Double click and install the .msi. Once the installation is over, look out for PartitionAW.sql in “C:\Program Files\Microsoft SQL Server\100\Samples\Engine\Administration\Partitioning\Scripts” . This script partitions the AdventureWorks tables -- TransactionHistory and TransactionHistoryArchive.
As given in the MSDN documentation:
TheTransactionHistory table contains sales records for the current year. This table is used primarily for inserting new records and updating them as required. The TransactionHistoryArchive table contains sales records older than the current year. This table is used primarily for SELECT queries and as a staging table for moving data into a data warehouse. For more information about the partitioning design of these tables, see Planning Guidelines for Partitioned Tables and Indexes.
After running the query, the output is as shown below: