DBCC CHECKIDENT RESEED 0
By Tan Lee Published on Dec 12, 2024 241
SQL RESEED identity to 0
This will reset the identity seed of the table's identity column to 0
.
DBCC CHECKIDENT (table_name, RESEED, 0)
This means that the next time a new row is inserted, the identity column will start at 1
(because the next value is always seed + 1
).
If you have a table called Customers
with an identity column called CustomerID
, and you want to reset the identity column seed to 0
.
DBCC CHECKIDENT ('Customers', RESEED, 0)
Output
Checking identity information: current identity value '640'. DBCC execution completed. If DBCC printed error messages, contact your system administrator. Completion time: 2024-12-12T11:01:11.4837763+07:00
After this, the next record inserted into the Customers
table will have an CustomerID
of 1
(if 1
is the next increment based on your identity column's increment value).
If the identity column is using an increment of 1
, reseeding to 0
will result in the next insert having the value 1
. This will not affect the data in the table; it just resets the counter for the identity column.
- How to Download ODBC Driver for SQL Server
- How to Download SQL Server Management Studio (SSMS) Versions
- How to Query JSON in SQL Server
- How to modify JSON in SQL Server
- How to set time to 00:00:00 with GETDATE() in SQL
- How to find all the dependencies of a table in SQL Server
- How to Find Objects Referencing a Table in SQL Server
- Case sensitivity in SQL Server