Streamlined threshold evaluation and corrected arithmetic overflow in SQL command
Streamlined threshold evaluation and corrected arithmetic overflow in SQL command

2 databases out of thousands caused an arithmetic overflow on the seed
evaluation.  It was occurring in the ABS function.  After various tests,
I decided to move the ABS evaluation to the next CTE and it worked
there.  Also, instead of looping through the row results and evaluation
the threshold every time, I put that code up into the query to only run
once.  It's now much faster.

wsmelton/dbatools,kozloski/dbatools,dsolodow/dbatools,sqlpadawan/dbatools,alevyinroc/dbatools,SirCaptainMitch/dbatools,Splaxi/dbatools