DBCC CHECKIDENT RESEED 0
By FoxLearn 12/12/2024 4:15:56 AM 109
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 convert timestamp to date in SQL Server
- How to Download and Restore Northwind database to SQL Server
- How to convert varchar to uniqueidentifier in SQL Server
- How to Download Microsoft SQL Server
- Saving changes is not permitted in SQL Server
- How to change ‘Edit Top 200 Rows’ and ‘Select Top 1000 Rows’ in SQL
- How to fix 'The specified sa password does not meet strong password requirements'
- How to Set Up Dark Theme in SQL Server Management Studio