- SQL code
declare @alive bit;set @alive = null;if @alive = 1 or @alive != 1 print 'Alive or Dead';else print 'Huh? Neither alive nor dead'; if @[email protected] PRINT 'It must equal itself, right?'ELSE PRINT 'Not always. null does not equal null';
Huh? Neither alive nor dead
Not always. null does not equal null
代码挺有意思的。
------解决方案--------------------
yes, null does not equal null!
------解决方案--------------------
- SQL code
declare @alive bit;set @alive = null;if @alive = 1 or @alive != 1 print 'Alive or Dead';else print 'Huh? Neither alive nor dead'; if null is null PRINT 'It must equal itself, right?'ELSE PRINT 'Not always. null does not equal null';/*Huh? Neither alive nor deadIt must equal itself, right?
------解决方案--------------------
Null is woman's looks
------解决方案--------------------
null does not equal null
------解决方案--------------------
- SQL code
What would be the output ?declare @a smallint set @a = 0 select nullif ( @a , '' )
------解决方案--------------------
NULL<>''
------解决方案--------------------
mark
------解决方案--------------------
null does not equal null!
null is null!
------解决方案--------------------
俺只会中文
NULL确实不能比较只能IS
------解决方案--------------------
改了配置已经可以比较哦
------解决方案--------------------
都是些外国人。呵呵 null是什么都没有的意思。所以由此所得 null就不是数字
------解决方案--------------------
is null
------解决方案--------------------
其实楼主是拉晒英文呢
------解决方案--------------------
null=undefined value=未知
------解决方案--------------------
set ansi_nulls off后结果就不同了.
- SQL code
set ansi_nulls offdeclare @alive bit;set @alive = null;if @alive = 1 or @alive != 1 print 'Alive or Dead';else print 'Huh? Neither alive nor dead'; if @[email protected] PRINT 'It must equal itself, right?'ELSE PRINT 'Not always. null does not equal null';--> 结果Alive or DeadIt must equal itself, right?
------解决方案--------------------
null确实不能比较 但是可以通过 isnull转化在比较 isnull(字段,'') 如果是NULL则转化为 ‘’ 空字符串
------解决方案--------------------
------解决方案--------------------
------解决方案--------------------