Last active
March 6, 2018 15:29
-
-
Save richardbasile/b3aaf285b507fda8a4383f641f71d323 to your computer and use it in GitHub Desktop.
SQL Server - Indexes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT t.name AS [TableName] | |
, i.name AS [IndexName] | |
, i.is_primary_key | |
, i.is_unique_constraint | |
, i.type_desc | |
, SUM(s.[used_page_count]) * 8 AS IndexSizeKB | |
FROM sys.indexes i | |
JOIN sys.tables t ON t.object_id = i.object_id | |
JOIN sys.dm_db_partition_stats s ON s.object_id = i.object_id AND s.index_id = i.index_id | |
GROUP BY t.name | |
, i.name | |
, i.is_primary_key | |
, i.is_unique_constraint | |
, i.type_desc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment