alter table test alter column 你的字段 int identity(初始值,每次增长多少) alter table test add primary key(id)
不行啊,我试过了!它提示 alter table test alter column id int identity(1,1)错误!
消息 156,级别 15,状态 1,第 1 行 关键字 'identity' 附近有语法错误。
select row_number()Over(Order by getdate() asc) as ID,...(不要自增列) into tb from t1
--查询条件语句 select * into t1 from (select * from t_25 where status =1 ) as s --删除主键自增长列 alter table t1 drop column id --更改目标列的数据 update t1 set status = 0,[time] = null,accesscode = null,secondaryTime = getdate() --更改原表中的数据状态 update t_25 set status = 4 where id in(select id from t_25 where status =1) --将改后的数据复制到原表中 insert into t_25 select * from t1 --删除中间表 drop table t1 我搞定了,求人,不若求己啊!
alter table test alter column 你的字段 int identity(初始值,每次增长多少)
alter table test add primary key(id)
select * into t1 from (select * from t_25 where status =1 ) as s
--删除主键自增长列
alter table t1 drop column id
--更改目标列的数据
update t1 set status = 0,[time] = null,accesscode = null,secondaryTime = getdate()
--更改原表中的数据状态
update t_25 set status = 4 where id in(select id from t_25 where status =1)
--将改后的数据复制到原表中
insert into t_25 select * from t1
--删除中间表
drop table t1
我搞定了,求人,不若求己啊!