Rajanand Ilangovan
Rajanand Ilangovan

Rajanand Ilangovan

List of indexes on a table with column details in SQL Server

Rajanand Ilangovan's photo
Rajanand Ilangovan
·Sep 20, 2022·

1 min read

List out all the indexes defined on a table and column details.

USE test_db;  

OBJECT_NAME(i.object_id) AS table_name
,i.type_desc AS index_type
,i.name AS index_name  
,COL_NAME(ic.object_id,ic.column_id) AS column_name
FROM sys.indexes AS i  
INNER JOIN sys.index_columns AS ic ON i.object_id = ic.object_id AND i.index_id = ic.index_id  
WHERE i.object_id = OBJECT_ID('dbo.table_name');

Result: image.png