selet * into #temp from table1 order by field1
alter table #temp add  newfield int identity(1,1)
truncate table table1
alter table table1 add  newfield int identity(1,1)
insert table1 (field1,field2) select field1,field2 from #temp
update table1 set field2=a.field1 from #temp a where a.newfield+1=table1.newfield 
alter table table1 drop column newfield

解决方案 »

  1.   

    selet * into #temp from table1 order by field1alter table #temp add  newfield int identity(1,1)truncate table table1alter table table1 add  newfield int identity(1,1)insert table1 (field1,field2) select field1,field2 from #tempupdate table1 set field2=a.field1 from #temp a where 
    a.newfield-1=table1.newfield alter table table1 drop column newfield
      

  2.   

    update table1set fd2=(select min(fd1) from table1 where fd1>a.fd1)
    from table1 a
      

  3.   

    update table1 set fd2=(select min(fd1) from table1 where fd1>a.fd1)
    from table1 a