Wednesday, March 14, 2012

Script to find the size of an Index

Simple query to find the size of  the indexes


	OBJECT_NAME(i.OBJECT_ID) AS TableName, AS IndexName,
	i.index_id AS IndexID,
	8 * SUM(a.used_pages)/1024 AS 'IndexSize in KB'
FROM sys.indexes AS i
JOIN sys.partitions AS p ON p.OBJECT_ID = i.OBJECT_ID AND p.index_id = i.index_id
JOIN sys.allocation_units AS a ON a.container_id = p.partition_id
WHERE i.object_id = object_id ('yourTableName')--- put the table name here
GROUP BY i.OBJECT_ID,i.index_id,


Post a Comment