almost 6 years ago
By using the seed value for every new record Microsoft SQL Server's identity column generates sequential values. In this post we will learn how to reseed an identity column.
Following is the command to reset the identity property :
DBCC CHECKIDENT (tablename, RESEED, reseed_value)
For example if we want to reset column identity to 10 for table Employee we will run the following command:
DBCC CHECKIDENT (Employee, RESEED, 10)
In case we want to delete rows from Employee table and restore the value to the previous value, we need to run the below query:
WHERE Employee_id >= 10 ;
DECLARE @Seed NUMERIC(10)
SELECT @Seed = MAX(Employee_id) FROM Employee ;
DBCC CHECKIDENT (Employee, RESEED, @Seed)
While using the above approach we should be careful not to set a new seed value below existing values as it will generate an error if column is a primary key.
Starting with Chrome version 45, NPAPI is no longer supported for Google Chrome. For more information, see Chrome and NPAPI (blog.chromium.org).
Firefox and Microsoft Internet Explorer are recommended browsers for websites using java applets.
Chrome Version Support
Are you sure, you want to delete this comment?
Terms of Service
| © copyright 2021 FindNerd.com. All rights reserved.
Sign up using