I have a routine that runs through all the non-clustered indexes in a given database on SQL2005 (SP3), and reorganizes and rebuilds them (if fragmentation > 20%). This process is erroring out on one index entry in sys.indexes. The index does not exist on the database in question, but still exists by name in sys.indexes.
My questions:
- Is there a way to find other such indexes in all databases?
- Is it safe to just delete the absent index(es) from sys.indexes? If not, how do I clean this up?
As always, thank you in advance for your assistance.