IndexInformation.sql 642 B

1234567891011121314151617181920
  1. IF OBJECT_ID ('dbo.IndexInformation','V') IS NOT NULL DROP VIEW dbo.IndexInformation
  2. GO
  3. CREATE VIEW dbo.IndexInformation
  4. AS
  5. SELECT
  6. t.name AS TableName,
  7. i.name AS IndexName,
  8. i.type_desc AS IndexType,
  9. c.name AS ColumnName,
  10. ic.is_included_column AS IsIncludedColumn
  11. FROM
  12. sys.indexes i
  13. INNER JOIN
  14. sys.index_columns ic ON i.object_id = ic.object_id AND i.index_id = ic.index_id
  15. INNER JOIN
  16. sys.columns c ON ic.object_id = c.object_id AND ic.column_id = c.column_id
  17. INNER JOIN
  18. sys.tables t ON i.object_id = t.object_id
  19. WHERE
  20. i.is_primary_key = 0 -- Exclude primary keys if you only want non-PK indexes