• saintor1 - Thursday, October 12, 2017 9:01 AM

    Thom A - Thursday, October 12, 2017 8:43 AM

    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.

    And this is why I didn't want to explain the problem. You are repeating your code 3 times. There's no use for that.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2