usp_AdaptiveIndexDefrag QUOTENAME(@dbName) issue
When @DebugMode =1 you have a few commands that contain QUOTENAME(@dbName) which are causing errors Error 911 has occurred while determining row modification counter. Message: Database '[WAREHOUSE_STAGE]' does not exist. Make sure that the name is entered correctly. (Line Number: 1)
The QuoteName is unnecessary because its already quoted when stored in the tbl_AdaptiveIndexDefrag_Stats_Working table
There are 9 occurrences of these that cause problems.
This problem occurs regardless of the @debugmode setting. I ran an extended event to capture errors with @debugmode=0 and the process throws the same Error 911. Back to Ola's solution I guess since this appears to be an ongoing problem.