SQL Server 2016 introduced a modification to the TRUNCATE TABLE statement which allows you to truncate a specific partition or set of partitions from a table:
TRUNCATE TABLE < tablename > WITH (PARTITIONS (< partition_id >));
An article about the TRUNCATE TABLE WITH PARTITIONS contains the next note:
To start using the new TRUNCATE TABLE statement option, make sure that all your table indexes are aligned with the source table. If there are non-aligned indexes in your table, drop or disable these indexes, truncate the partition(s) you want then rebuild the indexes again.
Does SQL Server 2016 provide an easy way (e.g. a query) to determine if the indexes of the partitioned tables are all aligned? (I want to avoid having to drop or disable indexes.)
Update 1
Example output of link:
*One index consists of 2 columns, but only one column is used in the partition function.
Is the index PK_TEST1 aligned or non-aligned?*
- index_name: PK_TEST1
- partition_function: psTEST1
- partition_ordinal: 1
- key_ordinal: 1
- is_included_column: 0
- columnName: COLUMN1
#
- index_name: PK_TEST1
- partition_function: psTEST1
- partition_ordinal: 0
- key_ordinal: 2
- is_included_column: 0
- columnName: COLUMN2