How to Partition Tables of the AdventureWorks Database

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:

image


About The Author

Suprotim Agarwal, MCSD, MCAD, MCDBA, MCSE, is the founder of DotNetCurry, DNC Magazine for Developers, SQLServerCurry and DevCurry. He has also authored a couple of books 51 Recipes using jQuery with ASP.NET Controls and a new one recently at The Absolutely Awesome jQuery CookBook.

Suprotim has received the prestigous Microsoft MVP award for nine times in a row now. In a professional capacity, he is the CEO of A2Z Knowledge Visuals Pvt Ltd, a digital group that represents premium web sites and digital publications comprising of Professional web, windows, mobile and cloud developers, technical managers, and architects.

Get in touch with him on Twitter @suprotimagarwal, LinkedIn or befriend him on Facebook

No comments: