Many times we need to find all indexes in a database, below query is use to find all indexes in a database SELECT S.NAME AS ‘SchemaName’, T.NAME AS ‘TableName’, I.NAME AS ‘IndexName’, C.NAME AS ‘ColumnName’, i.type_desc AS ‘IndexType’, CASE WHEN I.is_primary_key = 1 THEN ‘Yes’ ELSE ‘No’ END AS ‘IsPrimaryKey’ FROM SYS.TABLES AS T INNER JOIN SYS.SCHEMAS AS S ON T.SCHEMA_ID = S.SCHEMA_ID INNER JOIN SYS.INDEXES AS I ON I.OBJECT_ID = T.OBJECT_ID