SQL Server CASE WHEN OR THEN ELSE END => the OR is not supported - OmIndia

Teach To India

Tuesday, November 07, 2017

SQL Server CASE WHEN OR THEN ELSE END => the OR is not supported

SQL Server: CASE WHEN OR THEN ELSE END => the OR is not supported



  1. WHEN when_expression
    Is a simple expression to which input_expression is compared when the simple CASE format is used. when_expression is any valid expression. The data types of input_expression and each when_expression must be the same or must be an implicit conversion.
  2. WHEN Boolean_expression
    Is the Boolean expression evaluated when using the searched CASE format. Boolean_expression is any valid Boolean expression.


declare @a int,@b int
set @a=11
set @b=2
if(@a>@b)
Begin
select case when @a>1 then 1 else 2 end union select @a
End
else
begin
print @b
end

No comments:

Post a Comment

Comments

Popular