Unfortunately, this database is always online and fairly busy. It captures our netflow statistics from all our networking hardware.
I'm thinking we just need to put a check into the fetch loop to see if the table/index was deleted after the initial table/index query was done. (similar to the check for the index being disabled).
-- Loop through the tables, indexes and partitions.
INTO @indexid, @tableid, @indexname, @objectname, @schemaname, @indextype, @partitionnum, @partitioncount, @currentdensity, @currentfrag;
WHILE @@FETCH_STATUS = 0
SET @StatusMsg = @StatusMsg + @NewLine
-- ***** Check if index/table is still available, if not then do not process it, print message.