Using SQL Server Management Studio

Follow the steps in this procedure to create one or more filegroups, corresponding files, and a table. You will reference these objects in the next procedure when you create the partitioned table.

To create new filegroups for a partitioned table

  1. In Object Explorer, right-click the database in which you want to create a partitioned table and select Properties.
  2. In the Database Properties – database_name dialog box, under Select a page, select Filegroups.
  3. Under Rows, click Add. In the new row, enter the filegroup name.
  4. Continue adding rows until you have created all of the filegroups for the partitioned table.
  5. Click OK.
  6. Under Select a page, select Files.
  7. Under Rows, click Add. In the new row, enter a filename and select a filegroup.
  8. Continue adding rows until you have created at least one file for each filegroup.
  9. Expand the Tables folder and create a table as you normally would.

To create a partitioned table

  1. Right-click the table that you wish to partition, point to Storage, and then click Create Partition….
  2. In the Create Partition Wizard, on the Welcome to the Create Partition Wizard page, click Next.
  3. On the Select a Partitioning Column page, in the Available partitioning columns grid, select the column on which you want to partition your table. Only columns with data types that can be used to partition data will be displayed in the Available partitioning columns grid. If you select a computed column as the partitioning column, the column must be designated as a persisted column.

The choices you have for the partitioning column and the values range are determined primarily by the extent to which your data can be grouped in a logical way. For example, you may choose to divide your data into logical groupings by months or quarters of a year. The queries you plan to make against your data will determine whether this logical grouping is adequate for managing your table partitions. All data types are valid for use as partitioning columns, except textntextimagexmltimestampvarchar(max)nvarchar(max)varbinary(max), alias data types, or CLR user-defined data types.

The following additional options are available on this page:

Collocate this table to the selected partitioned table
Allows you to select a partitioned table that contains related data to join with this table on the partitioning column. Tables with partitions joined on the partitioning columns are typically queried more efficiently.

Storage-align non-unique indexes and unique indexes with an indexed partition column
Aligns all indexes of the table that are partitioned with the same partition scheme. When a table and its indexes are aligned, you can move partitions in and out of partitioned tables more effectively, because your data is partitioned with the same algorithm.

After selecting the partitioning column and any other options, click Next.

  • On the Select a Partition Function page, under Select partition function, click either New partition function or Existing partition function. If you choose New partition function, enter the name of the function. If you choose Existing partition function, select the name of the function you’d like to use from the list. The Existing partition function option will not be available if there are no other partition functions on the database.

After completing this page, click Next.

  • On the Select a Partition Scheme page, under Select partition scheme, click either New partition scheme or Existing partition scheme. If you choose New partition scheme, enter the name of the scheme. If you choose Existing partition scheme, select the name of the scheme you’d like to use from the list. The Existing partition scheme option will not be available if there are no other partition schemes on the database.

After completing this page, click Next.

  • On the Map Partitions page, under Range, select either Left boundary or Right boundary to specify whether to include the highest or lowest bounding value within each filegroup you create. You must always enter one extra filegroup in addition to the number of filegroups specified for the boundary values when you are creating partitions.

In the Select filegroups and specify boundary values grid, under Filegroup, select the filegroup into which you want to partition your data. Under Boundary, enter the boundary value for each filegroup. If boundary value is left empty, the partition function maps the whole table or index into a single partition using the partition function name.

The following additional options are available on this page:

Set Boundaries…
Opens the Set Boundary Values dialog box to select the boundary values and date ranges you want for your partitions. This option is only available when you have selected a partitioning column that contains one of the following data types: datedatetimesmalldatetimedatetime2, or datetimeoffset.

Estimate storage
Estimates rowcount, required space, and available space for storage for each filegroup specified for the partitions. These values are displayed in the grid as read-only values.

The Set Boundary Values dialog box allows for the following additional options:

Start date
Selects the starting date for the range values of your partitions.

End date
Selects the ending date for the range values of your partitions. If you selected Left boundary on the Map Partitions page, this date will be the last value for each filegroup/partition. If you selected Right boundary on the Map Partitions page, this date will be the first value in the next-to-last filegroup.

Date range
Selects the date granularity or range value increment you want for each partition.

After completing this page, click Next.

  • In the Select an Output Option page, specify how you want to complete your partitioned table. Select Create Script to create a SQL script based the previous pages in the wizard. Select Run immediately to create the new partitioned table after completing all remaining pages in the wizard. Select Schedule to create the new partitioned table at a predetermined time in the future.

If you select Create script, the following options are available under Script options:

Script to file
Generates the script as a .sql file. Enter a file name and location in the File name box or click Browse to open the Script File Location dialog box. From Save As, select Unicode text or ANSI text.

Script to Clipboard
Saves the script to the Clipboard.

Script to New Query Window
Generates the script to a new Query Editor window. This is the default selection.

If you select Schedule, click Change schedule.

  1. In the New Job Schedule dialog box, in the Name box, enter the job schedule’s name.
    1. On the Schedule type list, select the type of schedule:
      1. Start automatically when SQL Server Agent starts
      1. Start whenever the CPUs become idle
      1. Recurring. Select this option if your new partitioned table updates with new information on a regular basis.
      1. One time. This is the default selection.
    1. Select or clear the Enabled check box to enable or disable the schedule.
    1. If you select Recurring:
      1. Under Frequency, on the Occurs list, specify the frequency of occurrence:
        1. If you select Daily, in the Recurs every box, enter how often the job schedule repeats in days.
        1. If you select Weekly, in the Recurs every box, enter how often the job schedule repeats in weeks. Select the day or days of the week on which the job schedule is run.
        1. If you select Monthly, select either Day or The.
          1. If you select Day, enter both the date of the month you want the job schedule to run and how often the job schedule repeats in months. For example, if you want the job schedule to run on the 15th day of the month every other month, select Day and enter “15” in the first box and “2” in the second box. Please note that the largest number allowed in the second box is “99”.
          1. If you select The, select the specific day of the week within the month that you want the job schedule to run and how often the job schedule repeats in months. For example, if you want the job schedule to run on the last weekday of the month every other month, select Day, select last from the first list and weekday from the second list, and then enter “2” in the last box. You can also select firstsecondthird, or fourth, as well as specific weekdays (for example: Sunday or Wednesday) from the first two lists. Please note that the largest number allowed in the last box is “99”.
      1. Under Daily frequency, specify how often the job schedule repeats on the day the job schedule runs:
        1. If you select Occurs once at, enter the specific time of day when the job schedule should run in the Occurs once at box. Enter the hour, minute, and second of the day, as well as AM or PM.
        1. If you select Occurs every, specify how often the job schedule runs during the day chosen under Frequency. For example, if you want the job schedule to repeat every 2 hours during the day that the job schedule is run, select Occurs every, enter “2” in the first box, and then select hour(s) from the list. From this list you can also select minute(s) and second(s). Please note that the largest number allowed in the first box is “100”.

In the Starting at box, enter the time that the job schedule should start running. In the Ending at box, enter the time that the job schedule should stop repeating. Enter the hour, minute, and second of the day, as well as AM or PM.

  • Under Duration, in Start date, enter the date that you want the job schedule to start running. Select End date or No end date to indicate when the job schedule should stop running. If you select End date, enter the date that you want to job schedule to stop running.
    • If you select One Time, under One-time occurrence, in the Date box, enter the date that the job schedule will be run. In the Time box, enter the time that the job schedule will be run. Enter the hour, minute, and second of the day, as well as AM or PM.
    • Under Summary, in Description, verify that all job schedule settings are correct.
    • Click OK.

After completing this page, click Next.

  • On the Review Summary page, under Review your selections, expand all available options to verify that all partition settings are correct. If everything is as expected, click Finish.
  • On the Create Partition Wizard Progress page, monitor status information about the actions of the Create Partition Wizard. Depending on the options that you selected in the wizard, the progress page might contain one or more actions. The top box displays the overall status of the wizard and the number of status, error, and warning messages that the wizard has received.

The following options are available on the Create Partition Wizard Progress page:

Details
Provides the action, status, and any messages that are returned from action taken by the wizard.

Action
Specifies the type and name of each action.

Status
Indicates whether the wizard action as a whole returned the value of Success or Failure.

Message
Provides any error or warning messages that are returned from the process.

Report
Creates a report that contains the results of the Create Partition Wizard. The options are View ReportSave Report to FileCopy Report to Clipboard, and Send Report as Email.

View Report
Opens the View Report dialog box, which contains a text report of the progress of the Create Partition Wizard.

Save Report to File
Opens the Save Report As dialog box.

Copy Report to Clipboard
Copies the results of the wizard’s progress report to the Clipboard.

Send Report as Email
Copies the results of the wizard’s progress report into an email message.

When complete, click Close.

The Create Partition Wizard creates the partition function and scheme and then applies the partitioning to the specified table. To verify the table partitioning, in Object Explorer, right-click the table and select Properties. Click the Storage page. The page displays information such as the name of the partition function and scheme and the number of partitions.

Using Transact-SQL

To create a partitioned table

  1. In Object Explorer, connect to an instance of Database Engine.
  2. On the Standard bar, click New Query.
  3. Copy and paste the following example into the query window and click Execute. The example creates new filegroups, a partition function, and a partition scheme. A new table is created with the partition scheme specified as the storage location.
USE AdventureWorks2012;  
GO  
-- Adds four new filegroups to the AdventureWorks2012 database  
ALTER DATABASE AdventureWorks2012  
ADD FILEGROUP test1fg;  
GO  
ALTER DATABASE AdventureWorks2012  
ADD FILEGROUP test2fg;  
GO  
ALTER DATABASE AdventureWorks2012  
ADD FILEGROUP test3fg;  
GO  
ALTER DATABASE AdventureWorks2012  
ADD FILEGROUP test4fg;   
 
-- Adds one file for each filegroup.  
ALTER DATABASE AdventureWorks2012   
ADD FILE   
    NAME = test1dat1,  
    FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\t1dat1.ndf',  
    SIZE = 5MB,  
    MAXSIZE = 100MB,  
    FILEGROWTH = 5MB  
TO FILEGROUP test1fg;  
ALTER DATABASE AdventureWorks2012   
ADD FILE   
    NAME = test2dat2,  
    FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\t2dat2.ndf',  
    SIZE = 5MB,  
    MAXSIZE = 100MB,  
    FILEGROWTH = 5MB  
TO FILEGROUP test2fg;  
GO  
ALTER DATABASE AdventureWorks2012   
ADD FILE   
    NAME = test3dat3,  
    FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\t3dat3.ndf',  
    SIZE = 5MB,  
    MAXSIZE = 100MB,  
    FILEGROWTH = 5MB  
TO FILEGROUP test3fg;  
GO  
ALTER DATABASE AdventureWorks2012   
ADD FILE   
    NAME = test4dat4,  
    FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\t4dat4.ndf',  
    SIZE = 5MB,  
    MAXSIZE = 100MB,  
    FILEGROWTH = 5MB  
TO FILEGROUP test4fg;  
GO  
-- Creates a partition function called myRangePF1 that will partition a table into four partitions  
CREATE PARTITION FUNCTION myRangePF1 (int)  
    AS RANGE LEFT FOR VALUES (1, 100, 1000) ;  
GO  
-- Creates a partition scheme called myRangePS1 that applies myRangePF1 to the four filegroups created above  
CREATE PARTITION SCHEME myRangePS1  
    AS PARTITION myRangePF1  
    TO (test1fg, test2fg, test3fg, test4fg) ;  
GO  
-- Creates a partitioned table called PartitionTable that uses myRangePS1 to partition col1  
CREATE TABLE PartitionTable (col1 int PRIMARY KEY, col2 char(10))  
    ON myRangePS1 (col1) ;  
GO  
 

To determine if a table is partitioned

  1. The following query returns one or more rows if the table PartitionTable is partitioned. If the table is not partitioned, no rows are returned.
SELECT *   
FROM sys.tables AS t   
JOIN sys.indexes AS i   
    ON t.[object_id] = i.[object_id]   
    AND i.[type] IN (0,1)   
JOIN sys.partition_schemes ps   
    ON i.data_space_id = ps.data_space_id   
WHERE t.name = 'PartitionTable';   
GO  
 

To determine the boundary values for a partitioned table

  1. The following query returns the boundary values for each partition in the PartitionTable table.
SELECT t.name AS TableName, i.name AS IndexName, p.partition_number, p.partition_id, i.data_space_id, f.function_id, f.type_desc, r.boundary_id, r.value AS BoundaryValue   
FROM sys.tables AS t  
JOIN sys.indexes AS i  
    ON t.object_id = i.object_id  
JOIN sys.partitions AS p  
    ON i.object_id = p.object_id AND i.index_id = p.index_id   
JOIN  sys.partition_schemes AS s   
    ON i.data_space_id = s.data_space_id  
JOIN sys.partition_functions AS f   
    ON s.function_id = f.function_id  
LEFT JOIN sys.partition_range_values AS r   
    ON f.function_id = r.function_id and r.boundary_id = p.partition_number  
WHERE t.name = 'PartitionTable' AND i.type <= 1  
ORDER BY p.partition_number;  
 

To determine the partition column for a partitioned table

  1. The following query returns the name of the partitioning column for table. PartitionTable.
SELECT   
    t.[object_id] AS ObjectID   
    , t.name AS TableName   
    , ic.column_id AS PartitioningColumnID   
    , c.name AS PartitioningColumnName   
FROM sys.tables AS t   
JOIN sys.indexes AS i   
    ON t.[object_id] = i.[object_id]   
    AND i.[type] <= 1 -- clustered index or a heap   
JOIN sys.partition_schemes AS ps   
    ON ps.data_space_id = i.data_space_id   
JOIN sys.index_columns AS ic   
    ON ic.[object_id] = i.[object_id]   
    AND ic.index_id = i.index_id   
    AND ic.partition_ordinal >= 1 -- because 0 = non-partitioning column   
JOIN sys.columns AS c   
    ON t.[object_id] = c.[object_id]   
    AND ic.column_id = c.column_id   
WHERE t.name = 'PartitionTable' ;   
GO  

Modify a Partition Function

You can change the way a table or index is partitioned in SQL Server 2019 (15.x) by adding or subtracting the number of partitions specified, in increments of 1, in the partition function of the partitioned table or index by using Transact-SQL. When you add a partition, you do so by “splitting” an existing partition into two partitions and redefining the boundaries of the new partitions. When you drop a partition, you do so by “merging” the boundaries of two partitions into one. This last action repopulates one partition and leaves the other partition unassigned.

Limitations and Restrictions

  • ALTER PARTITION FUNCTION can only be used for splitting one partition into two, or for merging two partitions into one. To change the way a table or index is partitioned (from 10 partitions to 5, for example), you can use any one of the following options:
    • Create a new partitioned table with the desired partition function, and then insert the data from the old table into the new table by using either an INSERT INTO … SELECT FROM Transact-SQL statement or the Manage Partition Wizard in SQL Server Management Studio.
    • Create a partitioned clustered index on a heap.
    • Drop and rebuild an existing partitioned index by using the Transact-SQL CREATE INDEX statement with the DROP EXISTING = ON clause.
    • Perform a sequence of ALTER PARTITION FUNCTION statements.
  • SQL Server does not provide replication support for modifying a partition function. If you want to make changes to a partition function in the publication database, you must do this manually in the subscription database.
  • All filegroups that are affected by ALTER PARTITION FUNCTION must be online.

Permissions

Any one of the following permissions can be used to execute ALTER PARTITION FUNCTION:

  • ALTER ANY DATASPACE permission. This permission defaults to members of the sysadmin fixed server role and the db_owner and db_ddladmin fixed database roles.
  • CONTROL or ALTER permission on the database in which the partition function was created.
  • CONTROL SERVER or ALTER ANY DATABASE permission on the server of the database in which the partition function was created.

Using SQL Server Management Studio

To modify a partition function:

This specific action cannot be performed using SQL Server Management Studio. In order to modify a partition function, you must first delete the function and then create a new one with the desired properties using the Create Partition Wizard. For more information, see

To delete a partition function

  1. Expand the database where you want to delete the partition function and then expand the Storage folder.
  2. Expand the Partition Functions folder.
  3. Right-click the partition function you want to delete and select Delete.
  4. In the Delete Object dialog box, ensure that the correct partition function is selected, and then click OK.

Using Transact-SQL

To split a single partition into two partitions

  1. In Object Explorer, connect to an instance of Database Engine.
  2. On the Standard bar, click New Query.
  3. Copy and paste the following example into the query window and click Execute.
-- Look for a previous version of the partition function "myRangePF1" and deletes it if it is found.  
IF EXISTS (SELECT * FROM sys.partition_functions  
    WHERE name = 'myRangePF1')  
    DROP PARTITION FUNCTION myRangePF1;  
GO  
-- Create a new partition function called "myRangePF1" that partitions a table into four partitions.  
CREATE PARTITION FUNCTION myRangePF1 (int)  
AS RANGE LEFT FOR VALUES ( 1, 100, 1000 );  
GO  
--Split the partition between boundary_values 100 and 1000  
--to create two partitions between boundary_values 100 and 500  
--and between boundary_values 500 and 1000.  
ALTER PARTITION FUNCTION myRangePF1 ()  
SPLIT RANGE (500);  

To merge two partitions into one partition

  1. In Object Explorer, connect to an instance of Database Engine.
  2. On the Standard bar, click New Query.
  3. Copy and paste the following example into the query window and click Execute.
-- Look for a previous version of the partition function "myRangePF1" and deletes it if it is found.  
IF EXISTS (SELECT * FROM sys.partition_functions  
    WHERE name = 'myRangePF1')  
    DROP PARTITION FUNCTION myRangePF1;  
GO  
-- Create a new partition function called "myRangePF1" that partitions a table into four partitions.  
CREATE PARTITION FUNCTION myRangePF1 (int)  
AS RANGE LEFT FOR VALUES ( 1, 100, 1000 );  
GO  
--Merge the partitions between boundary_values 1 and 100  
--and between boundary_values 100 and 1000 to create one partition  
--between boundary_values 1 and 1000.  
ALTER PARTITION FUNCTION myRangePF1 ()  
MERGE RANGE (100);  
 

Modify a Partition Scheme

You can modify a partition scheme in SQL Server 2019 (15.x) by designating a filegroup to hold the next partition that is added to a partitioned table using SQL Server Management Studio or Transact-SQL. You do this by assigning the NEXT USED property to a filegroup. You can assign the NEXT USED property to an empty filegroup or to one that already holds a partition. In other words, a filegroup can hold more than one partition.

Limitations and Restrictions

Any filegroup affected by ALTER PARTITION SCHEME must be online.

Permissions

The following permissions can be used to execute ALTER PARTITION SCHEME:

  • ALTER ANY DATASPACE permission. This permission defaults to members of the sysadmin fixed server role and the db_owner and db_ddladmin fixed database roles.
  • CONTROL or ALTER permission on the database in which the partition scheme was created.
  • CONTROL SERVER or ALTER ANY DATABASE permission on the server of the database in which the partition scheme was created.

Using SQL Server Management Studio

To modify a partition scheme:

This specific action cannot be performed using SQL Server Management Studio. In order to modify a partition scheme, you must first delete the scheme and then create a new one with the desired properties using the Create Partition Wizard.

To delete a partition scheme

  1. Click the plus sign to expand the database where you want to delete the partition scheme.
  2. Click the plus sign to expand the Storage folder.
  3. Click the plus sign to expand the Partition Schemes folder.
  4. Right-click the partition scheme you want to delete and select Delete.
  5. In the Delete Object dialog box, ensure that the correct partition scheme is selected, and then click OK.

Using Transact-SQL

To modify a partition scheme

  1. In Object Explorer, connect to an instance of Database Engine.
  2. On the Standard bar, click New Query.
  3. Copy and paste the following example into the query window and click Execute.
USE AdventureWorks2012;  
GO  
-- add five new filegroups to the AdventureWorks2012 database  
ALTER DATABASE AdventureWorks2012  
ADD FILEGROUP test1fg;  
GO  
ALTER DATABASE AdventureWorks2012  
ADD FILEGROUP test2fg;  
GO  
ALTER DATABASE AdventureWorks2012  
ADD FILEGROUP test3fg;  
GO  
ALTER DATABASE AdventureWorks2012  
ADD FILEGROUP test4fg;  
GO  
ALTER DATABASE AdventureWorks2012  
ADD FILEGROUP test5fg;  
GO  
-- if the "myRangePF1" partition function and the "myRangePS1" partition scheme exist,  
-- drop them from the AdventureWorks2012 database  
IF EXISTS (SELECT * FROM sys.partition_functions  
    WHERE name = 'myRangePF1')  
DROP PARTITION FUNCTION myRangePF1;  
GO  
IF EXISTS (SELECT * FROM sys.partition_schemes  
    WHERE name = 'myRangePS1')  
DROP PARTITION SCHEME myRangePS1;  
GO  
-- create the new partition function "myRangePF1" with four partition groups  
CREATE PARTITION FUNCTION myRangePF1 (int)  
AS RANGE LEFT FOR VALUES ( 1, 100, 1000 );  
GO  
-- create the new partition scheme "myRangePS1"that will use   
-- the "myRangePF1" partition function with five file groups.  
-- The last filegroup, "test5fg," will be kept empty but marked  
-- as the next used filegroup in the partition scheme.  
CREATE PARTITION SCHEME myRangePS1  
AS PARTITION myRangePF1  
TO (test1fg, test2fg, test3fg, test4fg, test5fg);  
GO  
--Split "myRangePS1" between boundary_values 100 and 1000  
--to create two partitions between boundary_values 100 and 500  
--and between boundary_values 500 and 1000.  
ALTER PARTITION FUNCTION myRangePF1 ()  
SPLIT RANGE (500);  
GO  
-- Allow the "myRangePS1" partition scheme to use the filegroup "test5fg"  
-- for the partition with boundary_values of 100 and 500  
ALTER PARTITION SCHEME myRangePS1  
NEXT USED test5fg;  
GO  
 

Using Partition Wizard

Use the Manage Partition Wizard to manage and modify existing partitioned tables through partition switching or the implementation of a sliding window scenario. This wizard can ease the management of your partitions and simplify the regular migration of data in and out of your tables.

To start the Manage Partition Wizard

  • In SQL Server Management Studio, select the database, right-click the table on which you want to create partitions, point to Storage, and then click Manage Partition.

Note If Manage Partition is unavailable, you may have selected a table that does not contain partitions. Click Create Partition on the Storage submenu and use the Create Partition Wizard to create partitions in your table.

This section provides the information that is required to manage, modify, and implement partitions using the Manage Partition Wizard.

Select Partition Action Page

Use the Select Partition Action page to choose the action you want to perform on your partition.

Create a Staging Table

Partition switching is a common partitioning task if you have a partitioned table that you migrate data into and out of on a regular basis; for example, you have a partitioned table that stores current quarterly data, and you must move in new data and archive older data at the end of each quarter.

The wizard designs the staging table with the same partitioning column, table and column structure, and indexes, and stores the new table in the filegroup where your source partition is located.

To create a staging table to switch in or switch out partition data, select Create a staging table for partition switching.

Sliding Window Scenario

To manage your partitions in a sliding-window scenario, select Manage partitioned data in a sliding window scenario.

UI element list

Create a staging table for partition switching
Creates a staging table for the data you are switching in or switching out of the existing partitioned table.

Switch out partition
Provides options when removing a partition from the table.

Switch in partition
Provides options when adding a partition to the table.

Manage partitioned data in a sliding window scenario
Appends an empty partition to the existing table that can be used for switching in data. The wizard currently supports switching into the last partition and switching out the first partition.

Select Partition Switching-In Options Page

Use the Select Partition Switching-In options page to select the staging table you are switching into the partitioned table.

UI element list

Show All Partitions
Select to show all partitions, including the partitions currently in the partitioned table.

Partition grid
Displays the partition name, Left boundaryRight boundaryFilegroup, and Row count of the partitions you selected.

Switch in table
Select the staging table that contains the partition that you want to add to your partitioned table. You must create this staging table before you switch-in partitions with the Manage PartitionsWizard.

Select Partition Switching-Out Options Page

Use the Select Partition Switching-Out options page to select the partition and the staging table to hold the partitioned data that you are switching out of the partitioned table.

UI element list

Partition grid
Displays the partition name, Left boundaryRight boundaryFilegroup, and Row count of the partitions you selected.

Switch out table
Choose a new table or an existing table to switch-out your data to.

New
Enter a new name for the staging table you want to use for the partition to switch out of the current source table.

Existing
Select an existing staging table you want to use for the partition you want to switch out of the current source table. If the existing table contains data, this data will be overwritten with the data you are switching out.

Select the Staging Table Options Page

Use the Select the Staging Table Options page to create the staging table you want to use for switching your partitioned data.

Staging tables must reside in the same filegroup of the selected partition where the source table is located. The staging table must mirror the design of both the source table and the destination table.

You can also create the same indexes in the staging table that exist in the source partition. The staging table automatically contains a constraint based on the elements of the source partition. This constraint is typically generated from the boundary value of the source partition.

UI element list

Staging table name
Create a name for the staging table or accept the default name displayed in the edit box.

Switch partition
Select the source partition that you want to switch out of the current table.

New boundary value
Select or enter the boundary value you want for the partition in the staging table.

Filegroup
Select a filegroup for the new table.

Select Output Option Page

Use the Select Output Option page to specify how you want to complete the modifications to your partitions.

Create Script

When the wizard finishes, it creates a script in Query Editor to modify partitions in the table. Select Create Script if you want to review the script, and then execute the script manually.

Script to file
Generate the script to a .sql file. Specify either Unicode or ANSI text. To specify a name and location for the file, click Browse.

Script to Clipboard
Save the script to the Clipboard.

Script to New Query Window
Generate the script to a Query Editor window. If no editor window is open, a new editor window opens as the target for the script.

Run Immediately

Run immediately
Have the wizard finish modifications to the partitions when you click Next or Finish.

Schedule

Select to modify the table partitions at a scheduled date and time.

Change schedule
Opens the New Job Schedule dialog box, where you can select, change, or view the properties of the scheduled job.

New Job Schedule Page

Use the New Job Schedule page to view and change the properties of the schedule.

Options

Select the type of schedule you want for the SQL Server Agent job.

Name
Type a new name for the schedule.

Jobs in schedule
View the existing jobs that use the schedule.

Schedule type
Select the type of schedule.

Enabled
Enable or disable the schedule.

Recurring Schedule Types Options

Select the frequency of the scheduled job.

Occurs
Select the interval at which the schedule recurs.

Recurs every
Select the number of days or weeks between recurrences of the schedule. This option is not available for monthly schedules.

Monday
Set the job to occur on a Monday. Only available for weekly schedules.

Tuesday
Set the job to occur on a Tuesday. Only available for weekly schedules.

Wednesday
Set the job to occur on a Wednesday. Only available for weekly schedules.

Thursday
Set the job to occur on a Thursday. Only available for weekly schedules.

Friday
Set the job to occur on a Friday. Only available for weekly schedules.

Saturday
Set the job to occur on a Saturday. Only available for weekly schedules.

Sunday
Set the job to occur on a Sunday. Only available for weekly schedules.

Day
Select the day of the month the schedule occurs. Only available for monthly schedules.

of every
Select the number of months between occurrences of the schedule. Only available for monthly schedules.

The
Specify a schedule for a specific day of the week on a specific week within the month. Only available for monthly schedules.

Occurs once at
Set the time for a job to occur daily.

Occurs every
Set the number of hours or minutes between occurrences.

Start date
Set the date when this schedule will become effective.

End date
Set the date when the schedule will no longer be effective.

No end date
Specify that the schedule will remain effective indefinitely.

One Time Schedule Types Options

If you schedule a job to run once, you must select a date and time in the future.

Date
Select the date for the job to run.

Time
Select the time for the job to run.

Summary Page

Use the Summary page to review the options that you have selected on the previous pages.

UI element list

Review your selections
Displays the selections you have made for each page of the wizard. Click a node to expand and view your previously selected options.

Progress Page

Use the Progress page to monitor status information about the actions of the Manage Partition Wizard. Depending on the options that you selected in the wizard, the Progress page might contain one or more actions. The top box displays the overall status of the wizard and the number of status, error, and warning messages that the wizard has received.

Options

Details
Provides the action, status, and any messages that are returned from action taken by the wizard.

Action
Specifies the type and name of each action.

Status
Indicates whether the wizard action as a whole returned the value of Success or Failure.

Message
Provides any error or warning messages that are returned from the process.

Stop
Stop the action of the wizard.

Report
Create a report that contains the results of the Manage Partition Wizard. The options are:

  • View Report
  • Save Report to File
  • Copy Report to Clipboard
  • Send Report as Email

View Report
Open the View Report dialog box. This dialog box contains a text report of the progress of the Manage Partition Wizard.

Close
Close the wizard.