[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]
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 TransactionHistoryArchive. Before running the partition switch, the partition function for TransactionHistoryArchive is modified to receive the new partition. Also a CHECK constraint is added to table TransactionHistory. Following the partition switch, both the TransactionHistory table and the TransactionHistoryArchive 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 AdventureWorks2008R2 (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 Readme_PartitioningScript Sample.
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.