各位大虾,现在有个困扰时间较长的问题。如何通过sql语句在查询分析器中将id的标识改为“是”,也就是自动增1,谢谢。急
再使用以下语句操作时候,第二个alter出现错误,提示:column附近语法错误
alter table tablename
drop column id
go
alter table tablename
add column id int identity(1,1)
go
再使用以下语句操作时候,update tablename set编号1=编号出错。编号1和编号是两个字段吧
有数据的话
ALTER TABLE 表 ADD 编号1 bigint identity(1,1) not null
go
SET IDENTITY_INSERT 表 ON
go
update tablename set 编号1=编号
go
SET IDENTITY_INSERT 表 OFF
go
ALTER TABLE 表 DROP COLUMN 编号
go
exec sp_rename 表.编号1,编号
go
alter table tablename
drop column id
go
alter table tablename
add id int identity(1,1) not null
go