You didn't specify what you're comparing @notplinid to
when @notplinid = ??? then
BTW, dynamic SQL could be faster in some case than query with convoluted WHERE clause because execution plan created by query analyzer with one condition could be totaly wrong for another condition.
>I'm having some problems getting this query to work, based on a condition I want to set the where clause, but it keeps on telling me I have a syntax error near "like" I dont see any error, cant seem to figure this one out. I know I can do this with some dynamic SQL but I really dont want to do that because of speed concerns.
>
>WHERE
>case
> when @notplinid = then (plinid like @plinid+'%' or @plinid = '')
> else (plinid not like (@plinid+'%'))
>end
--sb--