简体   繁体   English

从表中删除内容后,如何在 C# 的内置 SQL 数据库中将自动增量重置为从 1 开始?

[英]How do I reset Auto-Increment to start from 1 in built-in SQL Database of C# after deleting contents from table?

How do I reset Auto-Increment to start from 1 in built-in SQL Database of C# after deleting contents from table ?从表中删除内容后,如何在 C# 的内置 SQL 数据库中将自动增量重置为从 1 开始?

在此处输入图片说明

The problem I am facing is that, when I delete all the contents from the table with the "DELETE" query and again try to insert new data the "Id" will start from 100 whereas I am expecting it to be start from 1. Can anyone help me to solve this issue where the Primary Key ie, "Id" starts from its seed which is "1" ?我面临的问题是,当我使用“DELETE”查询从表中删除所有内容并再次尝试插入新数据时,“Id”将从 100 开始,而我希望它从 1 开始。可以任何人都可以帮助我解决主键即“Id”从其种子“1”开始的问题?

在此处输入图片说明

you can set a new current identity value for the identity column with the query below您可以使用以下查询为标识列设置新的当前标识值

DBCC CHECKIDENT (mytable, RESEED, 0) DBCC CHECKIDENT (mytable, RESEED, 0)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM