switch case in where clause

Posted by Nimesh on Stack Overflow See other posts from Stack Overflow or by Nimesh
Published on 2010-05-11T12:28:32Z Indexed on 2010/05/11 12:34 UTC
Read the original article Hit count: 337

hi,

i need to check three conditions:

if @filter = 1
{
**select * from employeestable where rating is not null** 
}
else if @filter = 2
{
**select * from employeestable where rating is null** 
}
else
{
**select * from employeestable**     
}

This i need to do using a case statement. now i have more than 30 lines of query, if i use case i can reduce my code upto 70%
Please let mek now how can i do this.

© Stack Overflow or respective owner

Related posts about sql-server-2008

Related posts about sql-server-2005