update 表
set x = case when a = 1 then 'yy' else x end,
    y = case when b = 2 then 'pp' else y end

解决方案 »

  1.   

    笔误update 表
    set x = case when a = 1 then 'yy' else x end,
        q = case when b = 2 then 'pp' else q end
      

  2.   

    update 表 set x=case when a=1 then 'yy' else x end,Q=case when b=2 then 'pp' else Q end
      

  3.   

    提高效率:update 表 set x=case when a=1 then 'yy' else x end,Q=case when b=2 then 'pp' else Q end where a=1 or b=2
      

  4.   

    用n个SQL语句把它搞定:
    update 表A set 字段X='yy' where a=1
    update 表A set 字段Q='pp' where b=2
    ...
      

  5.   

    好象只能如上用  case when 了
    否则用if语句分好几两来写更麻烦。
      

  6.   

    类似这样:
    (case when a=1 then X='yy'  else '' end)
    (case when b=2 then Q='pp'  else '' end)
      

  7.   

    declare @a int
    declare @b int
    declare @X varchar(12)
    declare @Q varchar(12)
    set @a=1
    set @b=1
    case  when @a=1 then @X='YY' when @b=2 then @Q='pp' end
      

  8.   

    declare @a int
    declare @b int
    declare @X varchar(12)
    declare @Q varchar(12)
    set @a=1
    set @b=1
    select case  when @a=1 then @X='YY' when @b=2 then @Q='pp' end
      

  9.   

    update 表 set x=case when a=1 then 'yy' else x end,Q=case when b=2 then 'pp' else Q end