For,DECLARE @VAL1 float;
while executing this statement,
select convert(numeric(18,2),(case when 2=1 then @VAL1 else @VAL end ));
Sql server internally converts @VAL to Float(datatype of @VAL1) then compare gives you the output as zero.
DECLARE @VAL nvarchar(10);
DECLARE @VAL1 float;
set @VAL=' ';
set @VAL1=12.123;
select @VAL,@VAL1
select CONVERT(float,@VAL)--done by sql server internally
select convert(numeric(18,2),(case when 2=1 then @VAL1 else @VAL end ));
but,for DECLARE @VAL1 numeric(18,2)
it actually gets error at sql server internal conversion.
DECLARE @VAL nvarchar(10);
DECLARE @VAL1 numeric(18,2);
set @VAL=' ';
set @VAL1=12.123;
select @VAL,@VAL1
select CONVERT(numeric(18,2),@VAL)--at this point,sql sever unabled to convert @VAL to datatype Numeric
select convert(numeric(18,2),(case when 2=1 then @VAL1 else @VAL end ));