Sigerson (8/29/2013)
Doing all of that within one SQL statement or a With block is beyond me,...
It's beyond me, too. But then again, I wouldn't even try to do it with a single statement. Avoiding the loop or doing something "set based" does [font="Arial Black"]NOT [/font]mean doing it "within one SQL statement or a Withblock". Multiple set-based passes will be much faster than using a loop for this.
--Jeff Moden
Change is inevitable... Change for the better is not.