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)
 Using CASE in where

Author  Topic 

sqlnovice123
Constraint Violating Yak Guru

262 Posts

Posted - 2010-03-04 : 08:39:26
I need to use the below in a where condition . @ListID is passed as a parameter to the proc. Thanks for your help.

like trd.ListID =

CASE
WHEN @ListID = 'Single Inquiry' THEN
WHEN @ListID = 'Lists' THEN
ELSE 'All Inquiries' END

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-04 : 08:46:40
you can use below. only thing is that you need to have return value for each

WHERE trd.ListID =

CASE
WHEN @ListID = 'Single Inquiry' THEN value1
WHEN @ListID = 'Lists' THEN value2
ELSE value3 END
.....

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -