You're attempting to set the value of the variable @ret outside the CASE statement, and inside. Remove the assignment of the variable inside the sub-queries and it'll work fine.
(Also, yes, see Luis' link).
New "C" (which works). Awesome. Many thanks.
Great, but did you look at Luis' link?
Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
Larnu.uk