| 
 Posted by ZeldorBlat on 11/17/05 04:53 
>How about this: 
> 
>if @myparam = '' or @myparam is null 
>    @myparam = '%' 
>else 
>    @myparam = '%' + @myparam + '%' 
> 
>select ... 
>from mytable 
>where MyField like @myparam 
 
Actually, now that I've thought about it more, it would be silly (and 
wasteful) to pattern match to everything.  This might be better: 
 
select ... 
from mytable 
where (@myparam = '' or @myparam is null 
     or charindex(@myparam,[MyField]) > 0))
 
  
Navigation:
[Reply to this message] 
 |