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 2000 Forums
 SQL Server Development (2000)
 More case statement questions

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-06-15 : 08:27:39
Jason writes "If you have a record that matches multiple WHEN clauses within a case statement, which output will be returned? For example

Test1
A

case when Test1 is NULL then 0
when isnumeric(test1) = 0 then 1
when Test1 = 'A' then 2
else 3 end

Will the output be 1 or 2? The record passes both when clauses so which output will be returned? Does the case statement break after the first condition in a case statement is met?"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2006-06-15 : 08:28:46
Yes. CASE will always return the expression of the first condition that is true, and it will not evaluate the rest.
Go to Top of Page
   

- Advertisement -