Getting index table names

  • Hi,

    How can I get a table_name per known index_name?

    Thanks!

  • You can check in sys.indexes, though note that index names don't have to be unique across the database, just unique on a table, so there may be two or more indexes with the same name on different tables

    select name, object_name(object_id) AS TableName from sys.indexes

    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
  • select o.name,

    i.name

    from sysobjects o,

    sysindexes i

    where i.id=o.id

    and type in ('U','V')

    and i.name = 'INDEX_NAME'

    _____________________________________
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at Amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
  • Thanks a lot, it helped!

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

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