Returns the partition ID of the specified data or index partition name.
partition_id(table_name, partition_name[,index_name])
is the name for a table.
is the partition name for a table partition or an index partition.
is the name of the index of interest.
Returns the partition ID corresponding to the partition name testtable_ptn1 and index id 0 (the base table). The testtable must exist in the current database:
select partition_id("testtable", "testtable_ptn1")
Returns the partition ID corresponding to the partition name testtable_clust_ptn1 for the index name clust_index1. The testtable must exist in the current database:
select partition_id("testtable", "testtable_clust_ptn1", "clust_index1")
This is the same as the previous example, except that the user need not be in the same database as where the target table is located:
select partition_id("mydb.dbo.testtable", "testtable_clust_ptn1", "clust_index1")
You must enclose table_name, partition_name and index_name in quotes.
Functions data_pages, object_id, partition_name, reserved_pages, row_count, used_pages