Skip to content

Instantly share code, notes, and snippets.

@SBajonczak
Created December 14, 2021 11:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SBajonczak/0ef1b29447e8e7f422db4664763d71a2 to your computer and use it in GitHub Desktop.
Save SBajonczak/0ef1b29447e8e7f422db4664763d71a2 to your computer and use it in GitHub Desktop.
Get Index Size for each table in the Database
SELECT i.[name] AS IndexName
,SUM(s.[used_page_count]) * 8 AS IndexSizeKB
FROM sys.dm_db_partition_stats AS s
INNER JOIN sys.indexes AS i ON s.[object_id] = i.[object_id]
AND s.[index_id] = i.[index_id]
GROUP BY i.[name]
ORDER BY i.[name]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment