Thursday, 5 December 2013

Index Space Used

Every need to find out how much disk space an index takes up?:-

SELECT SUM(used_page_count) * 8 AS [Size in kb]

FROM sys.indexes i

JOIN sys.dm_db_partition_stats p ON p.object_id = i.object_id AND i.index_id = p.index_id

WHERE i.object_id=OBJECT_ID('dbo.TableName') AND i.name='Indexname'