Skip to main content

Posts

Showing posts from July, 2016

MS SQL Server: Finding and Eliminating Duplicate or Overlapping Indexes

This is cool query that worth to refering to in order to find duplicate index that can be removed.   However, I do not think the author should use " ORDER BY INDEX_COLUMN_DATA_KEY_COLS.key_ordinal" because the column order do not need to be same but still can be a duplicated indexed column. I would rather to use "ORDER BY COLUMN_DATA_KEY_COLS.name", this way, does not matter which order the column is indexed in the column list.   Same thing about "ORDER BY INDEX_COLUMN_DATA_INC_COLS.key_ordinal", I would use "ORDER BY COLUMN_DATA_INC_COLS.name"   Below is the link and query:   http://www.sqlservercentral.com/articles/Indexing/110106/   ; WITH CTE_INDEX_DATA AS ( SELECT SCHEMA_DATA . name AS schema_name , TABLE_DATA . name AS table_name , INDEX_DATA . name AS index_name , STUFF (( SELECT ', ' + COLUMN_DATA_KEY_COLS . name + ' ' + CASE WHEN