• CELKO (12/14/2012)


    .. Total failure.. Besides which, I believe my earlier post

    Yeah, it was awful! :crazy:

    What I wanted to do was avoid the CASE expression solution and go for something using functions that compile to simple assembly language.

    DELETE FROM Client_Shares

    WHERE COALESCE (SIGN(ABS(lm_id)+1), 0)

    + COALESCE (SIGN(ABS(ml_id) +1), 0)

    + COALESCE (SIGN(ABS(is_id) +1), 0)

    + COALESCE (SIGN(ABS(t_id)+1), 0) >= 2;

    Yep, and this one is total failure too (OP wasn't interested in code obfuscation;-))!

    Can you understand the simple fact that around 99% of projects/clients/developers/etc. DO NOT NEED PORTABILITY! Especially, as portability of SQL does not exist for now.

    If you really want to avoid CASE expression, it can be achieved in much more elegant way:

    DELETE t

    FROM trefClientShares t

    CROSS APPLY (SELECT COUNT(v) nnv

    FROM (VALUES (intLMid),(intMLid),(intISid),(intFRid)) v(v)) a

    WHERE a.nnv < 2

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]