How do I find all the tables and indexes that are partitioned?
If you have a huge number of partitioned tables and indexes then the following query would help you to identify the list of objects that are involved.
USE <database_name>;
GO
SELECT SCHEMA_NAME(o.schema_id) AS schema_name
,OBJECT_NAME(p.object_id) AS table_name
,i.name AS index_name
,p.partition_number
,rows
FROM sys.partitions AS p
INNER JOIN sys.indexes AS i ON p.object_id = i.object_id AND p.index_id = i.index_id
INNER JOIN sys.partition_schemes ps ON i.data_space_id=ps.data_space_id
INNER JOIN sys.objects AS o ON o.object_id = i.object_id
ORDER BY index_name, partition_number;
GO
**__________________________________**
SQL Server MVP, Sr. DBA & industry expert.
-
Knowledge is of two kinds. We know a subject ourselves or we know where we can find information on it. It is also a power and you will gain by sharing it.