有数据的话
ALTER TABLE 表 ADD 编号1 bigint identity(1,1) not null
go
SET IDENTITY_INSERT 表 ON
go
update 表 set 编号1=编号
go
SET IDENTITY_INSERT 表 OFF
go
ALTER TABLE 表 DROP COLUMN 编号
go
exec sp_rename '表.编号1','编号'
go
ALTER TABLE 表 ADD 编号1 bigint identity(1,1) not null
go
SET IDENTITY_INSERT 表 ON
go
update 表 set 编号1=编号
go
SET IDENTITY_INSERT 表 OFF
go
ALTER TABLE 表 DROP COLUMN 编号
go
exec sp_rename '表.编号1','编号'
go
ALTER TABLE tbTemp ID int IDENTITY(1, 1) not null
alter column不行要新建
alter column不行要新建
ALTER TABLE tbTemp ID int IDENTITY(1, 1) not null
2句语法都错了
ALTER TABLE tbTemp ID int IDENTITY(1, 1) not null
set identity_insert tbtemp on
update tbtemp set NewID=id
set identity_insert tbtemp offALTER TABLE tbTemp drop column ID
EXEC sp_rename 'tbtemp.Newid', 'ID', 'COLUMN'
无法更新标识列 'NewID'。