create table test(id int
)insert into test select nullinsert into test select nullinsert into test select null
insert into test select 230
insert into test select 250
insert into test select 433
select * from test
/*
将id列更新为如下形式id
1
2
3
4
5
6更新之后把id列设置为identity(1,1)进行递增,不知道可不可以
*/
drop table test
)insert into test select nullinsert into test select nullinsert into test select null
insert into test select 230
insert into test select 250
insert into test select 433
select * from test
/*
将id列更新为如下形式id
1
2
3
4
5
6更新之后把id列设置为identity(1,1)进行递增,不知道可不可以
*/
drop table test
create table test(id int)
insert into test select null
insert into test select null
insert into test select null
insert into test select 230
insert into test select 250
insert into test select 433
godeclare @i int
set @i=0update test set @i=@i+1,id=@iselect * from test
godrop table test
go
)insert into test select nullinsert into test select nullinsert into test select null
insert into test select 230
insert into test select 250
insert into test select 433
select * from testselect identity(int,1,1) as sid,id into #t from test
select id = sid from #t
drop table #tdrop table test
-------------------------------------------------------------
只能删除并重建ID列,无法修改。
---------------------------------------------------------
要是这样的话:alter table test add bh int identity(1,1)
alter table test drop column idexec sp_rename 'test.bh','id','column'