--try
update sz_bj set scbj=case when scbj is null then 0 end
where bjid=103

解决方案 »

  1.   

    --你描述不够准确,我也只能猜! scbj is null 的时候 更新成0,还是1 ?
      

  2.   

    scbj是NULL的时候用0代替,然后将scbj  update 为1
      

  3.   

    我不知道我上面的话是否表述清楚我的意思了,scbj 的值为0或NULL的改为1,怎么实现??
      

  4.   

    --那就是这个意思了??
    update sz_bj set scbj=case when scbj is null then 0  else 1 end
    where bjid=103
      

  5.   

    --scbj 的值为0或NULL的改为1,怎么实现??
    --
    update sz_bj set scbj=case when ( (scbj is null) or (scbj=0) ) then 1 end
    where bjid=103
      

  6.   

    显示isnull(scbj,0)不能做为左值, 所以是不能运行的.
    楼主要做什么?
    当bjid为103时,scbj赋什么值?
    是不是scbj为null时,赋值为0;不为null时,赋值为1?
    如果是这样的话,下面的方法就可以了
    update sz_bj
    set scbj=case when scbj is null then 0 else 1 end
    where bjid=103
      

  7.   

    /*回帖时,没看到上面的那些留言.
    如果要求是:"scbj是NULL的时候用0代替,
    然后将scbj  update 为1"的话,下面的就可以。
    楼上的,为什么要把where子句的限制条件,放在set子句里啊。
    那不是很麻烦吗?
    */
    update sz_bj
    set scbj=1
    where bjid=103
    and (scbj is null or scbj=0)
      

  8.   

    update sz_bj 
    set scbj=1 
    where bjid=103 and
          (scbj is null or scbj=0)或者
    update sz_bj 
    set scbj=(case when (scbj is null or scbj=0) then 1 else scbj end)
    where bjid=103
      

  9.   

    update sz_bj set scbj=case when scbj is null then 0  else 1 end
    where bjid=103
    是这样的吧。
      

  10.   

    --filebat(Mark)
    update sz_bj
    set scbj=1
    where bjid=103
    and (scbj is null or scbj=0)
    发现现在写SQL 好象有点思维定势了 -.- 呵呵
      

  11.   

    楼主的说法有点矛盾,,,是先后顺序,还是同时顺序,,是先把NULL替换为0,再替换为1,那还不如将字段为
    null 的值替换为1update sz_bj set scbj=case when ( (scbj is null) or (scbj=0) ) then 1 end
    where bjid=103
      

  12.   

    update sz_bj set scbj=1 where bjid=103 and isnull(scbj,0)=0