Advertisement
trietnv

IndexInformation

Sep 21st, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. select
  2. i.name 'indexes', '',i.type_desc 'indexetype', c.name 'column', '',s.name+'.'+t.name + '.' + c.name 'tables:columns'
  3. from sys.tables t
  4. inner join sys.schemas s on t.schema_id = s.schema_id
  5. inner join sys.indexes i on i.object_id = t.object_id
  6. inner join sys.index_columns ic on ic.object_id = t.object_id
  7. inner join sys.columns c on c.object_id = t.object_id and
  8. ic.column_id = c.column_id
  9.  
  10. where i.index_id > 0
  11. --and i.type in (1, 2) -- clustered & nonclustered only
  12. --and i.is_primary_key = 0 -- do not include PK indexes
  13. --and i.is_unique_constraint = 0 -- do not include UQ
  14. --and i.is_disabled = 0
  15. --and i.is_hypothetical = 0
  16. --and ic.key_ordinal > 0
  17. -- and s.name = 'metadata'
  18. order by s.name+'.'+t.name + '.' + c.name,ic.key_ordinal
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement