SELECT
p.partition_number AS [PartitionNumber],
p.data_compression AS [DataCompression],
prv.value AS [RightBoundaryValue],
fg.name AS [FileGroupName],
CAST(p.rows AS float) AS [RowCount]
FROM
sys.tables AS tbl
INNER JOIN sys.indexes AS idx ON idx.object_id = tbl.object_id and idx.index_id < 2
INNER JOIN sys.partitions AS p ON p.object_id=CAST(tbl.object_id AS int) AND p.index_id=idx.index_id
INNER JOIN sys.indexes AS indx ON p.object_id = indx.object_id and p.index_id = indx.index_id
LEFT OUTER JOIN sys.destination_data_spaces AS dds ON dds.partition_scheme_id = indx.data_space_id and dds.destination_id = p.partition_number
LEFT OUTER JOIN sys.partition_schemes AS ps ON ps.data_space_id = indx.data_space_id
LEFT OUTER JOIN sys.partition_range_values AS prv ON prv.boundary_id = p.partition_number and prv.function_id = ps.function_id
LEFT OUTER JOIN sys.filegroups AS fg ON fg.data_space_id = dds.data_space_id or fg.data_space_id = indx.data_space_id
WHERE
(tbl.name='table_name' and SCHEMA_NAME(tbl.schema_id)='dbo')
ORDER BY
[PartitionNumber] ASC
Комментариев нет:
Отправить комментарий