DBCC CHECKIDENT RESEED 0
By FoxLearn 12/12/2024 4:15:56 AM 150
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 and Restore Northwind database to SQL Server
- How to set time to 00:00:00 with GETDATE() in SQL
- Restoring MySQL Databases with mysqldump
- How to use Oracle linked server shows all tables
- Download backup of Northwind database for SQL Server
- How to Convert varchar to uniqueidentifier in SQL Server
- How to fix 'The transaction log for the database is full due to ACTIVE_TRANSACTION'
- How to use ROW_NUMBER Function in SQL Server