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
 General SQL Server Forums
 New to SQL Server Programming
 CASE statements

Author  Topic 

pazzy11
Posting Yak Master

145 Posts

Posted - 2007-08-23 : 05:03:56
Hi is it possible to have a case statement with 2 or more constraints ?

Like we have

CASE x
WHEN 1 THEN ..
WHEN 2 THEN ..

but what if i want a constraint like :
IF (x= 0 AND y=0)
{
then...
}

can this be done in a CASE statement ?
if not , can I use IF with SQL ?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-08-23 : 05:06:49
[code]case when x = 0 and y = 0 then . . . end[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-23 : 05:06:55
CASE
WHEN x = 1 THEN ..
WHEN x = 2 THEN ..
WHEN y > 0 AND z < 1 THEN ..



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

pazzy11
Posting Yak Master

145 Posts

Posted - 2007-08-23 : 09:41:21
ok thanks !!!

this seems to have worked...
Go to Top of Page
   

- Advertisement -