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

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

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

USE test_db;  
GO

SELECT 
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
,ic.index_column_id  
,ic.key_ordinal  
,ic.is_included_column  
,i.is_primary_key
,is_unique
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