| 1234567891011121314151617181920 |
- IF OBJECT_ID ('dbo.IndexInformation','V') IS NOT NULL DROP VIEW dbo.IndexInformation
- GO
- CREATE VIEW dbo.IndexInformation
- AS
- SELECT
- t.name AS TableName,
- i.name AS IndexName,
- i.type_desc AS IndexType,
- c.name AS ColumnName,
- ic.is_included_column AS IsIncludedColumn
- FROM
- sys.indexes i
- INNER JOIN
- sys.index_columns ic ON i.object_id = ic.object_id AND i.index_id = ic.index_id
- INNER JOIN
- sys.columns c ON ic.object_id = c.object_id AND ic.column_id = c.column_id
- INNER JOIN
- sys.tables t ON i.object_id = t.object_id
- WHERE
- i.is_primary_key = 0 -- Exclude primary keys if you only want non-PK indexes
|