TSQL : Compare variable with integer when variable is nothing

来源:互联网 发布:林弯弯淘宝店铺 编辑:程序博客网 时间:2024/04/30 16:50

IF(
(@FCCPROCESSSTATUS <>0 AND NOT(@FCCPROCESSSTATUS = 2 AND ISNULL(@DCCFLOWVERSION,0) = 2))

--(@FCCPROCESSSTATUS <>0 AND NOT(@FCCPROCESSSTATUS = 2 AND @DCCFLOWVERSION = 2))
 OR (@FOREIGNAMOUNT IS NOT NULL)
 )
BEGIN
Print 'DCCFlow : ' + cast( @DCCFLOWVERSION as varchar(10)) + '!!'
END
ELSE

BEGIN 
Print 'DCCFlow : nothing '
END

 

NOTE: when @DCCFLOWVERSION  is nothing(not null) , the first branch will not be reached!!!!

so the fix is the line highlighted in RED.