|
Posted by Erland Sommarskog on 07/29/05 18:29
(jcochran@rethinkllc.com) writes:
> I appreciate everyones help on this.
>
> What if I wanted to add another parameter named @AccountID. AccountID
> is used to track who created the ticket. @AccountID would be set to
> NULL just like @SearchTerm is. I wanted to be able to check to see if
> either was passed in. Sometimes both will be; other times it will be
> either/or.
>...
> IF NOT @AccountID IS NULL THEN
> AND AccountID = @AccountID
> END IF
AND (AccountID = @AccountID OR @AccountID IS NULL)
However, beware that if you want any index on AccuontID to be use, you
better split this up and have two different SELECT statements.
For a much longer discussion on a problem which you have not really
reached, but seem to be on your way to, I have an article on my web
site that you can save for a rainy day:
http://www.sommarskog.se/dyn-search.html.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp
Navigation:
[Reply to this message]
|