Resetting Identity column in SQL
Identity is one of the useful property in column. It will help us to create auto incrementing column in sql. Before the arrival of this property this requirement was done manually by adding 1 with the maximum value of the specific column. We can see this property vividly in this article.I hope this will be helpful. CREATE TABLE tblEmployee ( EmployeeId INT IDENTITY(1,1) NOT NULL, EmployeeName VARCHAR(50) ) Assume that we have inserted lots of records.Now we have to reset the identity value. DECLARE @maxValue INT SELECT @maxValue=ISNULL(MAX(EmployeeId),0) FROM tblEmployee DBCC CHECKIDENT ('[tblEmployee ]',RESEED,@maxValue) Now we have reset the identity column with the maximum record count of the table. Usually we will have situation to reset IDENTITY when " Primary key violation.cannot insert duplicate value.current identity value is()" this error comes.