update tablename set C=(case when C is not null then 1 else C end)
                    set D=(case when D is not null then 2 else D end)
                    ....E=...............................3.....E ....

解决方案 »

  1.   

    老大不对啊! 我的意思是 D列不为空时,此条记录的C列写入2
    update tablename set C=(case when C is not null then 1 else C end)
                     set C=(case when D is not null then 2 else D end)
                     ....C=...............................3.....E ....
    系统提示我多次出现C列怎么办呢?
      

  2.   

    //D列不为空时,此条记录的C列写入2update Tablename Set C=(Case D is not null then 2 else C end)
      

  3.   

    Sorry,再改//D列不为空时,此条记录的C列写入2update Tablename Set C=(Case when D is not null then 2 else C end)
      

  4.   

    老大,你好好看看我的问题好吗?你好想没明白我的意思!
    表a
    A B C D E
    a 4 4
    b 4 4
    c 6 6
    d 6 6
    e 6 6
    f 6 6
    表b
    A B C D E
    a 4 1
    b 4 1
    c 6 2
    d 6 1
    e 6 2
    f 6 3
    a表怎么能变成b表的效果呢?
    就是说当c列不为空,把c列值修改成1
    d列不为空,把c列值修改成2
    e列不为空,把c列值修改成3
    谢谢老大帮帮忙吧
      

  5.   

    update 表A set C=(case when C is not null then 1 else C end)
    update 表A set C=(case when D is not null then 2 else C end)
    update 表A set C=(case when E is not null then 3 else C end)
      

  6.   

    update tablename set C=(case when e is not null then 3 
                                 when d is not null then 2
                                 when c is not null then 1
                                else C end)
      

  7.   

    update   A  set  C=(case  when  C is not Null  then 1
    when  D is not Null  then 2
    when  E is not Null  then 3  end)