SHARE
Facebook X Pinterest WhatsApp

How to Reseed Your Identity Column Value in SQL Server

Written By
thumbnail
Gregory Larsen
Gregory Larsen
May 14, 2019

Have you deleted a bunch of rows from a table that has an identity column value? Do you now find that when you insert a new row, you find that the identity column value was set to one higher than the highest identity column value that your table original had? This can happen if you make a mistake and inserted a bunch of rows by accident, and then you delete those accidentally insert rows without reseeding your identity value.

If you have made this insert mistake or just delete a bunch of rows at the high end of the identify column value range, then you might want to reseed the identify column value, prior to adding any more rows. If you don’t reseed your identity value, then you might find that you have large gaps in your identify column values.

In order to reseed the identity column values, you can run this command:

DBCC CHECKIDENT ('youtable', RESEED, <new seed value>)

Where “<new seed value>” is set to the highest identify value in your table.  

After running the DBCC command your next inserted row into your table will be inserted with an identity column value 1 higher than the new seed value specified in the DBCC command.

You must use this command with care. Do not set the new seed value to be less than the highest identity column value in the table. If you set your new seed value to be less than the highest identity value in your table, then you might end up with SQL Server trying to insert a new identity value that has the same value of as an identity value already in your table. When this happens your insert statement will fail; therefore, be careful when you reseed the identity value on your tables.

# # #

See All Articles by Columnist Gregory A. Larsen

Recommended for you...

Best Online Courses to Learn SQL
Ronnie Payne
Sep 23, 2022
Best Courses for Database Administrators
Ronnie Payne
Jul 22, 2022
Tip 74 – Changing Cost Threshold for Parallelism
Gregory Larsen
Feb 24, 2021
How Many Databases Can You Name?
Brad Jones
May 11, 2020
Database Journal Logo

DatabaseJournal.com publishes relevant, up-to-date and pragmatic articles on the use of database hardware and management tools and serves as a forum for professional knowledge about proprietary, open source and cloud-based databases--foundational technology for all IT systems. We publish insightful articles about new products, best practices and trends; readers help each other out on various database questions and problems. Database management systems (DBMS) and database security processes are also key areas of focus at DatabaseJournal.com.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.