• Ok, I'm following what Kristoff has done there. I'm still unable to run because of the subquery returning multiple row problem.

    Am I correct that having multiple indexes named the same is a bad thing? Is there actually a requirement for the subquery

    (select index_id from sys.indexes where name=b.IndexName) As Index_id

    in the first place as Index_ID is in the IndexUsageInfo table?