SQL中自增型的字段,怎样重新按顺序生成标识? 在每次提交前執行:DBCC CHECKIDENT (jobs, RESEED, 你想要遞增的起始值) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 --有数据就用DBCC CHECKIDENT (表名, RESEED, 1) --1就是重新从1开始--没有数据的话,也可以用:truncate table 表名 另附:當設置SET IDENTITY_INSERT dbo.數據表 on 後,可插入遞增列的值 用临时表处理:select identity(int,1,1)as 自增列名,字段名(除自增字段) into #temp from your_table_namedrop table your_table_nameselect * into your_table_name from #tempselect * from your_table_name DBCC CHECKIDENT 并不能够使已经有的数据进行重排,我是想让已经存在的数据里边的自增型自段重新排列 midnight2002的方法可行,但如果表的数量比较多,或者表的数据比较多那岂不要很长的时间? 删除标识字段,再重新创建就可以了alter table 表 drop column 标识字段goalter table 表 add 标识字段 int identity(int,1,1) declare @num numeric(10)set @num=0update table set @num=id=@num+1 --從1遞增 alter table 表 drop column 标识字段goalter table 表 add 标识字段 int identity(int,1,1)---------------------------------------------------这个办法比较好 如何更改SQL排序规则 sql2005数据库邮件问题 charindex powerdesigner 生成测试数据,Test Data Profile 使用ODBC时,字符被截,??? full join 怎么不行啊??? 这个SQL语句看来只有比尔盖次能解了 为什么执行如下语句,出错? 记录网站设置,用一个表还是多个表? 【急】查询时间最大的去重复数据 [总结] 拆分字符串的函数 在数据库中查找用户的所有表,如果表中存在某个字段则删除它,应该怎么做? 讨论一下,如何用一段SQL语句递归找到一个目录下的所有子目录...
DBCC CHECKIDENT (表名, RESEED, 1) --1就是重新从1开始--没有数据的话,也可以用:
truncate table 表名
當設置SET IDENTITY_INSERT dbo.數據表 on 後,可插入遞增列的值
select identity(int,1,1)as 自增列名,字段名(除自增字段) into #temp from your_table_name
drop table your_table_name
select * into your_table_name from #temp
select * from your_table_name
go
alter table 表 add 标识字段 int identity(int,1,1)
set @num=0
update table
set @num=id=@num+1 --從1遞增
go
alter table 表 add 标识字段 int identity(int,1,1)
---------------------------------------------------
这个办法比较好