Do nothing in a sql statement--help

  • SELECT * FROM Table1 WHERE ID = @ID AND (@a> 0 OR @b-2>0)

    ... would fix a part of that but understood on the no return even if it has no rows. Thanks for the correction.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)
    Intro to Tally Tables and Functions

  • Jeff Moden (10/2/2009)


    SELECT * FROM Table1 WHERE ID = @ID AND (@a> 0 OR @b-2>0)

    ... would fix a part of that but understood on the no return even if it has no rows. Thanks for the correction.

    Honestly, I think that part of the specification is wrong, from a technical perspective, but since we haven't heard back after several people pointed that out, there's no way to know.

    I'd do pretty much the same thing as you did, but I'd have written it "and not(@a = 0 and @b-2 = 0)". Just reads more clearly to me, more direct translation of the business rule, no other reason. Though, depending on the values, you might need to check less than zero as well as greater than, to use your version. Again, no way to know without further data from the OP.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

Viewing 2 posts - 16 through 16 (of 16 total)

You must be logged in to reply to this topic. Login to reply