alter table a37 add myid int identity(1,1)
alter table a37 add tmyid int
--添加GO
GO
select * into #t from a37 order by a0188,a37107,a37103update #t set tmyid=myid
alter table #t drop column myid
alter table #t add newmyid int identity(1,1)
alter table a37 add tmyid int
--添加GO
GO
select * into #t from a37 order by a0188,a37107,a37103update #t set tmyid=myid
alter table #t drop column myid
alter table #t add newmyid int identity(1,1)
update #t set tmyid=myid
set IDENTITY_INSERT #t OFF
alter table a37 add tmyid intselect * into #t from a37 order by a0188,a37107,a37103update #t set tmyid=myid
exec('alter table #t drop column myid')
exec('alter table #t add newmyid int identity(1,1) ')
go --这里加Go看看
alter table #t drop column myid