update table set no=to_char(rownum+100)

解决方案 »

  1.   

    to LanZheng:
    原来的NO值是不规则的字符串。我用的是ms sql server 7
      

  2.   

    update table_name set no=(rownum+100);
    我已经试过肯定可以
      

  3.   

    to fxx:
    rownum是指什么?
    ms sql server 7好像不支持
      

  4.   

    assume that name of ur table is Table1 and primary key is column name NO
     
    create table #table_temp(RowNo int IDENTITY(100,1),NO char(3))
    insert into #table_temp (NO) 
           select NO from Table1update Table1
           set Table1.NO=convert(char(3),RowNo)
           from Table1,#table_temp
           where Table1.NO=#table_temp.NO
      

  5.   

    假定表为Table1 主键为NO 长度3create table #table_temp (RowNo int IDENTITY(100,1),NO char(3))insert into #table_temp (NO) 
           select NO 
                 from Table1update Table1
          set Table1.NO=convert(char(3),RowNo)
          from Table1,#table_temp
          where Table1.NO=#table_temp.NO
      

  6.   

    Declare UpdateNoCursor as cursor for
        select no,name,age from YourTableName
    declare @NoVal INT
    set @NoVal=100
    open UpdateNoCursor
    fetch next from UpdateNoCursor
    while @@fetch_status=0
        begin
           update YourTableName set no=@NoVal
           fetch next from UpdateNoCursor
           set @NoVal=@NoVal+1
        end
    close UpdateNoCursor
    deallocate UpdateNoCursor
      

  7.   

    Declare UpdateNoCursor as cursor for
        select no,name,age from YourTableName
    declare @NoVal INT
    set @NoVal=100
    open UpdateNoCursor
    fetch next from UpdateNoCursor
    while @@fetch_status=0
        begin
           update YourTableName set no=convert(char(3),@NoVal)
           fetch next from UpdateNoCursor
           set @NoVal=@NoVal+1
        end
    close UpdateNoCursor
    deallocate UpdateNoCursor
      

  8.   

    whitesky已经回答了是对的给他加分吧