Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Listing Tables and Indexes

By Uday,

Once in a while, a DBA or SQL developer is in the need of listing all the indexes of one or more tables in a given database.

Though the indexes can be viewed by using sp_help <table name> for a table, it does not help when it comes for multiple tables. Here the DBA's nice-to-have query is one to list Tables and Indexes.

Let's go and derive the query to list all the tables and their indexes.

For testing these queries in the test database, it is nice to have few tables created.
See the script for examples./

- sysobjects consists of all the objects in the database, while sysindexes has only index details.

Now, let's write the query in step by step fashion.

Query 1 - List all indexes in a database

Query 2 - Now let's exclude dtproperties table (indid = 255) and each tablename itself (indid =0) stored in sysindexes

Query 3 - List objects created by users

Query 4 - Let's build the complete query by joining both sysobjects and sysindexes.

Total article views: 3319 | Views in the last 30 days: 9
Related Articles

Noncluster at sysindexes

Noncluster at sysindexes


object_name(id) returning Null



Table not showing PK - PK is in sysindexes ?

Tables missing indexes but there seem to be entries for the indexes already in sysindexes ?



SQL2000, errors 8929,8928,8939,8965,8964 on SYSINDEXES


Indexes rebuilding problem

Indexes line present in sysindexes but not in sysobjects


Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones