Logic Query using IF statement

Bandi
Posted by Bandi under Sql Server category on | Points: 40 | Views : 280
declare @v_c int = 250;
declare @v_res int;
if(@v_c > 100)
set @v_res = 2* @v_c;
else if @v_c > 200
set @v_res = 3* @v_c;
else
set @v_res = 4* @v_c;
Print @v_res;


In the above code the both of conditions are TRUE. so what will be the output of above code ?
IF...ELSEIF statement will passes in the sequential order. Hence the result is 500 ( i.e. 2*250 = 500)

Comments or Responses

Login to post response