How to use a parameter that is not equal to.........

  • I have a stored procedure that returns records by a patient's location in the hospital. I want to be able to return all records EXCEPT those in location = C3. Is there a way to do this without having a dropdown listing all of the different locations?

  • I have a stored procedure that returns records by a patient's location in the hospital. I want to be able to return all records EXCEPT those in location = C3. Is there a way to do this without having a dropdown listing all of the different locations?

    Create a parameter for Locations, @Location

    Then in your filter,

    Expression: <Location>

    Operator: <> "not equals"

    Value: [@Location]

  • Here's some ideas.

    Create a true / false check box labeled "Except". Keep your existing list of all of the possible choices in the drop down.

    If the user checks the box, parse the list of locations in the proc and do EXISTS or NOT EXISTS, depending upon the value of the check box.

    This may be somewhat confusing to the users. I'm also guessing that the number of locations is fairly large and the drop down goes off the screen!

    You also may want to consider three underlying procs.

    The first "main" proc calls either one of two other procs. One proc is for the "except", the other is for include.

    Michael L John
    If you assassinate a DBA, would you pull a trigger?
    To properly post on a forum:
    http://www.sqlservercentral.com/articles/61537/

  • Thanx.

Viewing 4 posts - 1 through 3 (of 3 total)

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