create table test
( name varchar(20),
 type varchar(20)
)
insert into test select 'a1','半挂车'
insert into test select 'a2','半挂车'
insert into test select 'a3','半挂车'
insert into test select 'a4','半挂车'
insert into test select 'a5','半挂车'
insert into test select 'a6','半挂车'select * from test
/*
写一句update语句,把name列更新为'1','2','3'.....依次递增name         type1            半挂车
2            半挂车
3            半挂车
4            半挂车
5            半挂车
6            半挂车
*/
drop table test

解决方案 »

  1.   

    update test set [name]=right([name],len([name])-1)
      

  2.   

    create table test
    ( name varchar(20),
     type varchar(20)
    )
    insert into test select 'a1','半挂车'
    insert into test select 'a2','半挂车'
    insert into test select 'a3','半挂车'
    insert into test select 'a4','半挂车'
    insert into test select 'a5','半挂车'
    insert into test select 'a6','半挂车'Update A Set name = (Select Count(*) From test Where name <= A.name) From test A
    select * from test
      

  3.   

    leo_lesley(leo) ( ) 信誉:100    Blog   加为好友  2007-06-11 09:44:01  得分: 0  
     
     
       update test set [name]=right([name],len([name])-1)
      
     
    ---------如果超過10個,就有問題了。 :)
      

  4.   

    同意 paoluo(一天到晚游泳的鱼) 的解
      

  5.   

    如果超過10個,就有問題了。 :)
    只去掉哪个a字符是不会有错的.因为他永远都是len([name])-1.
      

  6.   

    应该不会阿~~  我是从右面取得,只要前面的字母是固定的一个a,应该不会出错误。
    create table test
    ( name varchar(20),
     type varchar(20)
    )
    insert into test select 'a1','半挂车'
    insert into test select 'a2','半挂车'
    insert into test select 'a3','半挂车'
    insert into test select 'a4','半挂车'
    insert into test select 'a5','半挂车'
    insert into test select 'a6','半挂车'
    insert into test select 'a7','半挂车'
    insert into test select 'a8','半挂车'
    insert into test select 'a9','半挂车'
    insert into test select 'a10','半挂车'
    insert into test select 'a11','半挂车'
    insert into test select 'a12','半挂车'
    update test set [name]=right([name],len([name])-1)
    select * from testdrop table test
    ----------result-----------------name                 type                 
    -------------------- -------------------- 
    1                    半??
    2                    半??
    3                    半??
    4                    半??
    5                    半??
    6                    半??
    7                    半??
    8                    半??
    9                    半??
    10                   半??
    11                   半??
    12                   半??(12 row(s) affected)
      

  7.   

    看錯了,如果前面是只有一個字符(比如a)開頭的,後面的數字都是不間斷的話,update test set [name]=right([name],len([name])-1)
    這個沒有問題