Determining the number of pages in a partition

You can use the ptn_data_pgs function or the dbcc checktable and dbcc checkdb commands to determine the number of data pages in a table’s partitions.

See the System Administration Guide for information about dbcc.

The ptn_data_pgs function returns the number of data pages on a partition. Its syntax is:

ptn_data_pgs(object_id, partition_id)

This example prints the number of pages in each partition of the sales table:

select partitionid, 
ptn_data_pgs(object_id("sales"), partitionid) Pages
from syspartitions 
where id = object_id("sales")

For a complete description of ptn_data_pgs, see the Adaptive Server Reference Manual.

The value returned by ptn_data_pgs may be inaccurate. If you suspect that the value is incorrect, run update partition statistics, dbcc checktable, dbcc checkdb, or dbcc checkalloc first, and then use ptn_data_pgs.