Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to list indexes for all tables 1

Status
Not open for further replies.

ColinGregory

Technical User
Feb 16, 2001
39
US
Does anyone know how to create a new table or view showing what indexes exist for all the tables in a database??

The information I need to know is table name, index name and index type. I've been messing about with combining sp_msforeachtable and sp_helpindex but with no success.

Thanks in advance
 
All the indexs are held in a system table within the database called sysindexes. Used in conjunction with the system table sysobjects the following query should get you started on what you want.

select sysobjects.name as Table_name, sysindexes.name as Index_name
from sysobjects , sysindexes
where sysobjects.type = 'U' and sysobjects.id = sysindexes.id


The type 'U' in sysobjects means you will only pick up the User tables you have created within the database.

Rick.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top