Caritatis

Just another WordPress.com weblog

Searching for all or one May 27, 2011

Filed under: Email — caritatis @ 8:30 pm

Since I only do this once or twice a year, I always forget the trick.  If you need to search on an id (or full text) and you want everything or just that id, use isnull, ex:

and s.SportID = isnull(@SportID,s.SportID)

It doesn’t seem to work as I’d like for a left outer join.  You can put it in the left outer join “on” clause, but if you have an id and nothing matches it, you get everything–not the empty set I’d like to get.  If you put it in the where clause and there is no id, you get nothing–even though I’d like to get everything.

Advertisement
 

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.