Readme_SlidingWindow
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.
Important
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.
Scenarios
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.
Languages
Transact-SQL
Prerequisites
Before you run this sample, install SQL Server 2005 and make sure you include the following components:
- Database Engine
- SQL Server Management Studio
- AdventureWorks (OLTP) sample database which is included with SQL Server 2005, and is also available at the Microsoft SQL Server Developer Center.
- SQL Server Database Engine samples. These samples are included with SQL Server 2005. You can download the latest version of the samples at the Microsoft SQL Server Developer Center.
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.
In SQL Server Management Studio, open the file Sliding.sql. The default installation directory is C:\Program Files\Microsoft SQL Server\90\Samples\Engine\Administration\SlidingWindow\Scripts, and then click Execute.
See Also
Tasks
Other Resources
Partitioned Tables and Indexes
Designing Partitions to Manage Subsets of Data
Transferring Data Efficiently by Using Partition Switching