Friday, February 5, 2021

SQL SERVER GET INDEX SIZE

 SELECT OBJECT_SCHEMA_NAME(i.OBJECT_ID) AS SchemaName,

       OBJECT_NAME(i.OBJECT_ID) AS TableName,

       i.[name] AS IndexName,

       i.index_id AS IndexID,

       8 * SUM(a.used_pages)/1024 AS [Indexsize(MB)]

FROM sys.indexes i

JOIN sys.partitions p ON p.OBJECT_ID = i.OBJECT_ID AND p.index_id = i.index_id

JOIN sys.allocation_units a ON a.container_id = p.partition_id

where i.name in ('IX_WIPIN',

'IX_CreatedOn',

'PK_T_SerialNo4',

'IX_T_SFCompTrace_IntSN',

'IX_Component',

'IX_TDID_ExtSerialNo',

'IX_WIPIN',

'IX_T_TDStructure_MBSN')

GROUP BY i.OBJECT_ID, i.index_id, i.[name]

ORDER BY OBJECT_NAME(i.OBJECT_ID), i.index_id

No comments:

Post a Comment