Hi All,
Variable with value 0 enters the loop when checked for blank value.
Example:-
--case 1:- when variable is checked with blank value
DECLARE @var1 INT
SET @var1=0
IF (@var1='')
BEGIN
select @var1 'Var value is Blank'
END
ELSE
BEGIN
select @var1 'Var value is not Blank'
END
--case 2:- when variable is checked with blank varchar value with implicit conversion
DECLARE @var2 INT,@var4 varchar
SET @var2=0
SET @var4=''
IF (@var2=@var4)
BEGIN
select @var2 'Var value is Blank'
END
ELSE
BEGIN
select @var2 'Var value is not Blank'
END
--case 3:- when variable is checked with blank varchar value with explicit conversion
DECLARE @var3 INT,@var5 varchar
SET @var3=0
SET @var5=''
IF (@var3=CAST(@var5 as int))
BEGIN
select @var3 'Var value is Blank'
END
ELSE
BEGIN
select @var3 'Var value is not Blank'
END
There are 3 case illustrations above in all the cases zero valued integer is getting equated to a blank value .
Is the value zero(0) and blank('') in Sql Server for an integer is same?