问题描述
我从 SQL Server 数据库的表中删除了一些记录.
I've deleted some records from a table in a SQL Server database.
表中的 ID 如下所示:
The IDs in the table look like this:
9910010112001201……
99 100 101 1200 1201...
我想删除后面的记录(ID > 1200),然后我想重置自动增量,这样下一个自动生成的 ID 将是 102.所以我的记录是连续的,有没有办法在 SQL Server 中做到这一点?
I want to delete the later records (IDs >1200), then I want to reset the auto increment so the next autogenerated ID will be 102. So my records are sequential, Is there a way to do this in SQL Server?
推荐答案
发出以下命令以重新播种 mytable 以从 1 开始:
Issue the following command to reseed mytable to start at 1:
DBCC CHECKIDENT (mytable, RESEED, 0)
在在线书籍(BOL、SQL 帮助)中阅读有关它的信息.还要注意您的记录不要高于您设置的种子.
Read about it in the Books on Line (BOL, SQL help). Also be careful that you don't have records higher than the seed you are setting.
这篇关于删除后重置 SQL Server 中的自动增量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)