partition_id

Description

Returns the partition ID of the specified data or index partition name.

Syntax

partition_id(table_name, partition_name[,index_name])

Parameters

table_name

is the name for a table.

partition_name

is the partition name for a table partition or an index partition.

index_name

is the name of the index of interest.

Examples

Example 1

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")

Example 2

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")

Example 3

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")

Usage

You must enclose table_name, partition_name and index_name in quotes.

See also

Functions data_pages, object_id, partition_name, reserved_pages, row_count, used_pages