techques
asked on
How to use case in MSSQL 2005?
Hi
I have a select query which needs to take clientid as where condition. However, if the clientid=0, then it needs to select all result.
I have a select query which needs to take clientid as where condition. However, if the clientid=0, then it needs to select all result.
Select * from client where type=1 and clientid=2
if clientid=0 which I pass it from C#
then
Select * from client where type=1 //and clientid=0 would be taken out
I tried:
Select * from client where type=1
case when (t.clientid ='0' then '' when t.clientid <> '0' then and t.clientid = '2') order by [id] desc
But, it said Incorrect syntax near the keyword 'case'.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER