Listing Index Dimensions of Tables in SQL Server

Hello to everyone,

In this article, I will try to give information about listing the Index dimensions of tables in SQL Server.

In SQL Server, in some cases you may want to list the Index dimensions of the tables.

You can easily do this using the code below.

SELECT sys_schemas.name AS SchemaName,
       sys_objects.name AS TableName,
       sys_indexes.name AS IndexName,
       sys_indexes.type_desc AS IndexType,
       partition_stats.used_page_count * 8 AS IndexSizeKB,
       CAST(partition_stats.used_page_count * 8 / 1024.00 AS Decimal(10, 3))AS IndexSizeMB,
       CAST(partition_stats.used_page_count * 8 / 1048576.00 AS Decimal(10, 3)) AS IndexSizeGB
FROM sys.dm_db_partition_stats partition_stats
INNER JOIN sys.indexes sys_indexes ON partition_stats.[object_id] = sys_indexes.[object_id]
AND partition_stats.index_id = sys_indexes.index_id
AND sys_indexes.type_desc <> 'HEAP'
INNER JOIN sys.objects sys_objects ON sys_objects.[object_id] = partition_stats.[object_id]
INNER JOIN sys.schemas sys_schemas ON sys_objects.[schema_id] = sys_schemas.[schema_id]
AND sys_schemas.name <> 'SYS' --WHERE partition_stats.[object_id] = object_id('dbo.TableName')
ORDER BY 1,
         2,
         3,
         4

When you run the above code, you will see a result similar to the one below.

As you can see, we have listed the Index dimensions of the tables.

Listing Index Dimensions of Tables in SQL Server

As you can see, we have listed the Index dimensions of the tables.

Good luck to everyone in business and life.

135 Views

Yavuz Selim Kart

I try to explain what I know in software and database. I am still improving myself by doing research on many programming languages. Apart from these, I am also interested in Graphic Design and Wordpress. I also have knowledge about SEO and Social media management. In short, I am a determined person who likes to work hard.

You may also like...

Don`t copy text!