if  exists (select 1 from  tablename1  where 商品数=null  and 商品CD=@商品CD )    begin
      update tablename1  
             set   商品数=@商品数
                   where 商品CD= @商品CD
else
    ....
----------------------------------------------------------
 tablename1表中 商品数字段是int型可以为null,为什么update执行后 商品数字段没有值,我语句写的有错误吗?

解决方案 »

  1.   

    if  exists (select 1 from  tablename1  where 商品数 is null  and 商品CD=@商品CD )
      

  2.   

    if  exists (select 1 from  tablename1  where 商品数 is null  and 商品CD=@商品CD )
      

  3.   

    商品数=null  --這句有問題, 要用is null來判斷
      

  4.   

    我觉得你的意思是:
    空(NULL)值和空白的区别,对吗?
    没有两个相等的空值