This sample works only with SQL Server 2005 and SQL Server 2008. It will not work with any version of SQL Server earlier than SQL Server 2005.
The purpose of the SlidingWindow sample is to demonstrate the ability to move partitions between tables by using the Transact-SQL ALTER TABLE SWITCH statement. For information about this feature, see "Designing Partitions to Manage Subsets of Data"
in SQL Server Books Online.
|Samples are provided for educational purposes only. They are not intended to be used in a production environment and have not been tested in a production environment. Microsoft does not provide technical support for these samples. Sample applications should
not be connected to or used with your production SQL Server database without the permission of the system administrator.
The sample moves the oldest month of data from the partitioned table TransactionHistory
to the partitioned table
. Before running the partition switch, the partition function for
is modified to receive the new partition. Also a CHECK constraint is added to table
. Following the partition switch, both the TransactionHistory
table and the
table are restored to a partitioning structure that would allow for a similar plan to run the following month.
Before you run this sample, follow these steps.
- Install SQL Server and make sure that you include the following components:
- Database Engine
- SQL Server Management Studio
- Download the AdventureWorks (OLTP) sample database and SQL Server Database Engine samples available at the
Microsoft SQL Server Samples and Community Projects Web site.
Running the Sample
The following procedure shows how to run the SlidingWindow sample.
To run the SlidingWindow sample
- Run the PartitioningScript sample. For more information, see
- In SQL Server Management Studio, open the file Sliding.sql. The default installation directory is C:\Program Files\Microsoft SQL Server\100\Samples\Engine\\Administration\SlidingWindow\Scripts, and then click
Execute. © 2008 Microsoft Corporation. All rights reserved.