| title | ALTER PARTITION SCHEME (Transact-SQL) | |||||
|---|---|---|---|---|---|---|
| description | ALTER PARTITION SCHEME adds a filegroup to a partition scheme or alters the designation of the NEXT USED filegroup for the partition scheme. | |||||
| author | markingmyname | |||||
| ms.author | maghan | |||||
| ms.date | 09/26/2025 | |||||
| ms.service | sql | |||||
| ms.subservice | t-sql | |||||
| ms.topic | reference | |||||
| ms.custom |
|
|||||
| f1_keywords |
|
|||||
| helpviewer_keywords |
|
|||||
| dev_langs |
|
|||||
| monikerRange | =azuresqldb-current || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current || =fabric-sqldb |
[!INCLUDE SQL Server Azure SQL Database Azure SQL Managed Instance FabricSQLDB]
Adds a filegroup to a partition scheme or alters the designation of the NEXT USED filegroup for the partition scheme.
Learn more about filegroups and partitioning strategies in Filegroups.
Note
In [!INCLUDE ssazure-sqldb] and [!INCLUDE fabric-sqldb], only primary filegroups are supported.
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions
ALTER PARTITION SCHEME partition_scheme_name
NEXT USED [ filegroup_name ] [ ; ]
The name of the partition scheme to be altered.
Specifies the filegroup to be marked by the partition scheme as NEXT USED. This means the filegroup accepts a new partition that is created by using an ALTER PARTITION FUNCTION statement.
In a partition scheme, only one filegroup can be designated NEXT USED. A filegroup that is not empty can be specified. If filegroup_name is specified and there currently is no filegroup marked NEXT USED, filegroup_name is marked NEXT USED. If filegroup_name is specified, and a filegroup with the NEXT USED property already exists, the NEXT USED property transfers from the existing filegroup to filegroup_name.
If filegroup_name is not specified and a filegroup with the NEXT USED property already exists, that filegroup loses its NEXT USED state so that there are no NEXT USED filegroups in partition_scheme_name.
If filegroup_name is not specified, and there are no filegroups marked NEXT USED, ALTER PARTITION SCHEME returns a warning.
Any filegroup affected by ALTER PARTITION SCHEME must be online.
The following permissions can be used to execute ALTER PARTITION SCHEME:
-
ALTER ANY DATASPACEpermission. This permission defaults to members of the sysadmin fixed server role and the db_owner and db_ddladmin fixed database roles. -
CONTROLorALTERpermission on the database in which the partition scheme was created. -
CONTROL SERVERorALTER ANY DATABASEpermission on the server of the database in which the partition scheme was created.
The following example assumes the partition scheme MyRangePS1 and the filegroup test5fg exist in the current database.
ALTER PARTITION SCHEME MyRangePS1
NEXT USED test5fg;Filegroup test5fg receives any additional partition of a partitioned table or index as a result of an ALTER PARTITION FUNCTION statement.