Simple Case Statement Example

Posted by Rajesh_Kumar under Sql Server category on | Points: 40 | Views : 1106
Case works as a IF Condition.

Declare @val int;
set @val = 3;

Select case(@val) when 1 then 'One' when 2 then 'Two' when 3 then 'Three' else 'Not a number in the range' end as Number_Text

Output will be: Three

Comments or Responses

Login to post response