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 a WHERE clause

Author  Topic 

demonickat
Starting Member

4 Posts

Posted - 2010-06-22 : 11:02:09
Hi,

I am trying to use a CASE in my WHERE clause

I have the clause like this

AND CASE @Report WHEN 'COV' THEN 'CBTY'
WHEN 'BRO' THEN 'BTYTR' END = @Report

Basically I am passing a parameter through as I want it to report on different types of regions depending on what is in @report

Is my logic correct? It should bring back rows, i.e if I do AND Report = 'CBTY' it brings back 95 rows. However once I use the CASE statement it brings nothing back.

Thanks

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2010-06-22 : 11:27:03
Nope, that doesn't make any logical sense. Unless you made a typo. Is the last @Report just supposed to be Report, as in Report the column?
Go to Top of Page
   

- Advertisement -