query on indexes

  • I have a particular table that has several indexes.

    How can I write (a) T-sql statement(s) that will show me

    1. The different indexes produced against the table.

    2. The columns associated with each index.

    Your help is appreciated.

  • sp_help tablename

    ---------------------------------------------------------------------

  • and

    sp_helpindex tablename

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • Keep in mind that these system procs do not return information about included columns, which you may or may not need to know about.

    └> bt



    Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • Write a query that retrieves from sys.indexes, sys.index_columns and sys.columns. Will show key and include columns.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply