• sql_2005_fan - Tuesday, January 24, 2017 4:42 AM

    The reason why I wanted to do this is.. I wanted to minimize the usage of the view 'EmplyeeCodes'.
     Each time i used 'exists' this object is queried once... I was thinking if there is way I can check all the condition with one select.

    Unfortunately, I was not able to think a way of doing this.

    Thanks.

    Your statements are all quite different, so 3 does seem the logical choice here. If you are meant to only get one result out of the 3, then using END ELSE IF BEGIN will cut them down.

    Are you saying that your query runs slowly then? Perhaps the problem is not with doing 3 EXiSTS, and that being slow, but that your VIEW is, and that needs a review.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk