本人想用SQL將'A' 轉化為 'B',依次類推
該如何實現?
還望各位大蝦出手相助!
謝謝!

解决方案 »

  1.   

    select char(ascii('A')+1)
    /*
    ----
    B(1 行受影响)
    */
      

  2.   


    select char(ascii('A')+1)  
    到了Z,就不能这样了
      

  3.   

    -->创建表
    if object_id('tb') is not null
      drop table tb
    goCREATE TABLE tb(NAME VARCHAR(20)) 
    insert tb select 'A'
    insert tb select 'B'
    insert tb select 'C'
    select char(ascii(name)+1) name from tb
    /*
    name
    ----
    B
    C
    D(3 行受影响)
    */
      

  4.   

    加一个判断应该可以的吧
    有没有更好的办法呢?期待ing~~
      

  5.   

    应该考虑下Z,Z转换为A的话select  name =case when name<>'Z' then char(ascii(name)+1) else 'A'
     from tb
      

  6.   

    应该考虑下Z,Z转换为A的话 select  name =case when name <>'Z' then char(ascii(name)+1) else 'A' end
    from tb 
      

  7.   

    declare @i int,@t varchar(20)
    set @t='Z'
    select @i=ascii(@t)
    if(@i>89) set @i=64
    set @i=@i+1
    select char(@i)/*
         
    ---- 
    A(所影响的行数为 1 行)*/
      

  8.   

    原來還有ascii這個函數可以使用
    呵呵  
    學習了結貼給分
      

  9.   

    update tb set col=char(ascii('A')+1) where col='A' update tb set col='B' where col='A'