Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Searching on nullable bit

Author  Topic 

alanmac
Starting Member

26 Posts

Posted - 2011-01-17 : 03:45:04
Hi,

I have a query which lets the user pass in up to 12 parameters from a search page and I return the matching results. My WHERE clause generally looks like this:

AND ((@ParkingPermitIssued is null) or (vc.ParkingPermitIssued = @ParkingPermitIssued))
AND ((@TownID is null) or (a.TownID = @TownID))

However, I have a column (DateOfForumMembership) which is type DATETIME and can be null. The user can pass in a parameter (@ForumMember) which can be null (don't search on this criteria), true or false.

How would I adapt my WHERE clause to accommodate this?

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2011-01-17 : 04:36:33
You might want to read through this before you walk down that road. That will not perform well.
http://sqlinthewild.co.za/index.php/2009/03/19/catch-all-queries/

--
Gail Shaw
SQL Server MVP
Go to Top of Page

alanmac
Starting Member

26 Posts

Posted - 2011-01-17 : 06:09:29
Thanks GilaMonster,

I have adapted my SP to use the format suggested in that post.
Go to Top of Page
   

- Advertisement -