Sunday, January 19, 2025
HomeProgrammingHow can I reset the identity seed after deleting records in SQL...

How can I reset the identity seed after deleting records in SQL Server?

To reset the identity seed after deleting records in SQL Server, use the DBCC CHECKIDENT command. This command resets the identity value to the specified seed or the current maximum value in the table. Here’s an example:

See also  How can I find which Version of a Package is Installed using PIP in Python?

DELETE FROM your_table;

— Reset the identity seed
DBCC CHECKIDENT (‘your_table’, RESEED, 0);

In this example, after deleting records from your_table, the identity seed is reset to 0. If you want the next inserted row to start with a different value, adjust the RESEED parameter accordingly.

RELATED ARTICLES
0 0 votes
Article Rating

Leave a Reply

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
- Advertisment -

Most Popular

Recent Comments

0
Would love your thoughts, please comment.x
()
x