问题:一张表,Table1,表中有两个字段,ID和Value,
表中有部分ID是在原有的一些ID上统一加了一个字符,比如'Z'
那么我想把这部分加了字符的ID的Value值加到原有的ID上.比如ID='z123456'的Value值放到ID='123456'中,请问SQL语句怎么写?谢谢,记录比较多不能一条条改.

解决方案 »

  1.   

    update T
    set value='z'+rtrim(ID)
      

  2.   

    select [value]='z '+rtrim(ID) from T--查询
      

  3.   

    假定ID是字符类型,
    update table1 set id = right(id, len(id) - 1) where id like 'Z%'
    或者update table1 set id = right(id, len(id) - 1) where not isnumeric(id)
      

  4.   

    id是PRIMARY KEY,SQL SERVER 2000数据库,,在线等啊谢谢!
      

  5.   


    update table1 set value=b.value from table1 a,table2 b where a.id='Z'+b.id
      

  6.   

    update a set a.value=b.value from table1 a,table1 b where a.id=substring(b.id,2,len(b.id)-1) 
      

  7.   

    怎么不行?
    update   a   set   a.value=b.value   from   table1   a,table1   b   where   a.id=substring(b.id,2,len(b.id)-1)   
      

  8.   

    update a set a.value=a.value+b.value from table1 a,table1 b where a.id=substring(b.id,2,len(b.id-1))