Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
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)

Find Duplicate Indexes

By Jeff Weisbecker,

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

Total article views: 2594 | Views in the last 30 days: 8
 
Related Articles
FORUM

Is this Index Duplicate

Confusion on index duplication

FORUM

Duplicate column name

Duplicate column name

FORUM

All INDEX details query - gives duplicate entires

I mixed and matched many queries tto give all details of index needed for analysis. Howeever, the qu...

ARTICLE

Duplicate Indexing Woes

Why would you ever create duplicate indexes? Does that even make sense? Steve Jones isn't sure, and ...

ARTICLE

Finding and Eliminating Duplicate or Overlapping Indexes

Duplicate & Overlapping Indexes can be a drag on write speed and disk resources. How do we find and...

Tags
indexing    
miscellaneous    
t-sql    
 
Contribute