一樓的,你試試看,行嗎?create table a(id int identity(1,1),item varchar (10)) insert into a values('a') insert into a values('b') insert into a values('c')select * from aSET IDENTITY_INSERT [a] ON update a set id=(select max(id)+1 from a) where id=2 SET IDENTITY_INSERT [a] off--drop table aServer: Msg 8102, Level 16, State 1, Line 2 Cannot update identity column 'id'.
可以用 select * into #a from TB WHERE 你的条件 delete tb from tb a,#a b where a.自动编号=b.自动编号 insert into tb (除了自动编号以后的所有字段) select (除了自动编号以后的所有字段) from #a drop table #a
insert into a values('a')
insert into a values('b')
insert into a values('c')select * from aSET IDENTITY_INSERT [a] ON
update a set id=(select max(id)+1 from a) where id=2
SET IDENTITY_INSERT [a] off--drop table aServer: Msg 8102, Level 16, State 1, Line 2
Cannot update identity column 'id'.
select * into #a from TB
WHERE 你的条件
delete tb from tb a,#a b where a.自动编号=b.自动编号
insert into tb (除了自动编号以后的所有字段)
select (除了自动编号以后的所有字段) from #a
drop table #a
这种建表格式是改不了的