There are plenty of scripts out there that find duplicate indexes, but they all seem to use cursors. I didn't want to use a cursor so I ended up creating a few that could handle the duplicates and decided to share this one.
This will return the table name and the names of the two identical indexes. If you would like to return indexes with a different number of columns, but the same sequence of columns then comment out the last condition in the SQL statement. For example, if you would like to return Index #1 as a duplicate of Index #2.
Index #1
Column 2
Column 3
Index #2
Column 2
Column 3
Column 4
Retrieve Index Information For All Tables - V2
This is an update to sp_helpindex, it allows you to pass the table name and whether you want to retrieve clustered, nonclustered or primary key indexes for a table. Using the sp_msforeach table will allow you to do this for all tables in a database. Inserting the data into a table will allow you to […]
2004-03-04
1,001 reads