Advertisement
cbossie

All Index Size

Mar 24th, 2020
457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.43 KB | None | 0 0
  1. SELECT
  2. OBJECT_SCHEMA_NAME(i.OBJECT_ID) AS SchemaName,
  3. OBJECT_NAME(i.OBJECT_ID) AS TableName,
  4. i.name AS IndexName,
  5. i.index_id AS IndexID,
  6. 8 * SUM(a.used_pages) AS 'Indexsize(KB)'
  7. FROM sys.indexes AS i
  8. JOIN sys.partitions AS p ON p.OBJECT_ID = i.OBJECT_ID AND p.index_id = i.index_id
  9. JOIN sys.allocation_units AS a ON a.container_id = p.partition_id
  10. GROUP BY i.OBJECT_ID,i.index_id,i.name
  11. ORDER BY OBJECT_NAME(i.OBJECT_ID),i.index_id
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement