大尾巴狼

所谓大尾巴狼,就是装腔作势。

列相等与不等

declare @f1 int, @v1 int
set @f1=null
set @v1=null
if @f1=@v1 or (@f1 is null and @v1 is null) print '相同' else print '不同'
if @f1<>@v1 or (@f1 is null and @v1 is not null) or (@f1 is not null and @v1 is null)
 print '不同' else print '相同'

print '------------------------------------------'
set @f1=1
set @v1=1
if @f1=@v1 or (@f1 is null and @v1 is null) print '相同' else print '不同'
if @f1<>@v1 or (@f1 is null and @v1 is not null) or (@f1 is not null and @v1 is null)
 print '不同' else print '相同'

print '------------------------------------------' 
set @f1=1
set @v1=null
if @f1=@v1 or (@f1 is null and @v1 is null) print '相同' else print '不同'
if @f1<>@v1 or (@f1 is null and @v1 is not null) or (@f1 is not null and @v1 is null)
 print '不同' else print '相同'

print '------------------------------------------'
set @f1=null
set @v1=1
if @f1=@v1 or (@f1 is null and @v1 is null) print '相同' else print '不同'
if @f1<>@v1 or (@f1 is null and @v1 is not null) or (@f1 is not null and @v1 is null)
 print '不同' else print '相同'

print '------------------------------------------'
set @f1=0
set @v1=1
if @f1=@v1 or (@f1 is null and @v1 is null) print '相同' else print '不同'
if @f1<>@v1 or (@f1 is null and @v1 is not null) or (@f1 is not null and @v1 is null)
 print '不同' else print '相同'

print '------------------------------------------' 

解决由于Null致使逻辑运算产生的误差

posted on 2010-01-23 22:46  大尾巴狼  阅读(401)  评论(0编辑  收藏  举报

导航