select id,Case id when '1' then 'A' else id end from A表

解决方案 »

  1.   


    select id,Case c when '1' then 'A' else c end from A表
      

  2.   

    select id,case when c='1' then 'a' else c end
    from a
      

  3.   

    楼上的写法都没有问题,不过前提,列C的定义不能为INT,只能为CHAR或者VARCHAR,否则就会出现转换错误.
      

  4.   

    应该没有问题,int可以直接转换为字符型,倒回去有的转换不过去。select id,c=Case id when '1' then 'A' else c end from A表
      

  5.   

    为了预防万一:
    select id,C=Case id when 1 then 'A' else convert(varchar,c) end  from  A表
      

  6.   

    我要查询是
    select A表 
    if 字段C 的 值为 1 则 显示 A
    else 显示原值-----------------------
    Select  Id,C=case when C=1  then 'A'  else cast(C as varchar(4))  end  from A