[thelist] To Store or Not to Store - Building dynamic queries

jason.handby jason.handby at corestar.co.uk
Wed Aug 16 14:24:39 CDT 2006


> Now, I need to modify this to allow for the user having defined a city
> to search within.  This would be the obvious addition 
> (assuming @city is
> declared) :
> 
> WHERE [KEY] = a.listing_id AND city LIKE @city
> 
> But, this does not allow for the possibility the user might have NOT
> defined a city, in which case the "AND city LIKE @city" 
> clause needs to
> not exist.
> 
> So, I'm back to my original question: How do I dynamically 
> include "AND
> city LIKE @city" in my stored proc?

  WHERE @city IS NULL OR city LIKE @city



Jason



More information about the thelist mailing list