DBCC CHECKIDENT RESEED 0
By FoxLearn 12/12/2024 4:15:56 AM 33
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 Set Up Dark Theme in SQL Server Management Studio
- How to drop temporary table if exists
- How to convert timestamp to date in SQL Server
- How to convert SQL Server's timestamp column to datetime format
- How to convert varchar to uniqueidentifier in SQL Server
- How to Read Excel file and Import data from Excel to SQL Server in C#
- Connection string odbc
- If else condition in sql server