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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Where clause

Author  Topic 

vivo
Starting Member

24 Posts

Posted - 2010-05-11 : 23:44:46
Can use if statement in where clause ??

if @param ='Y' then where clause should include "item not in ('a', 'b', 'c')"

if @param ="N' then where clause shouldn't include the above condition

sql-programmers
Posting Yak Master

190 Posts

Posted - 2010-05-12 : 00:34:16
Use the where class,

WHERE ((@Param='Y' and item not in ('a', 'b', 'c')) OR (@Param='N'))


SQL Server Programmers and Consultants
http://www.sql-programmers.com/
Go to Top of Page
   

- Advertisement -