Resetting the seed of SQL Server self-growing columns
Transferred from: http://hi.baidu.com/zbphot/item/41c55982c2d02dd05e0ec184
If the data in the table is not available, use the following statement: TRUNCATE TABLE
If the statement in the table is also, use the following statement: DBCC checkident (table name, reseed, 1)
DBCC checkident (' table_name ', noreseed) does not reset the current identity value.
DBCC Checkident Returns a report that indicates the current identity value and the expected identity value.
DBCC CHECKIDENT (' table_name ') or DBCC CHECKIDENT (' table_name ', reseed) if the current identity value of the table is less than the maximum identity value stored in the column, it is reset with the maximum value in the identity column.
The current value of DBCC checkident (' table_name ', reseed, New_reseed_value) is set to New_reseed_value. If a row has not been inserted into the table since the table was created, the first row inserted after the DBCC checkident is executed uses new_reseed_value as the identity. Otherwise, the next inserted row will use New_reseed_value + 1. If the value of new_reseed_value is less than the maximum value in the identity column, a No. 2627-number error message is generated later when the table is referenced.
If the statement in the table is also, use the following statement:
DBCC checkident (table name, reseed, 1)
DBCC checkident (' table_name ', noreseed) does not reset the current identity value.
DBCC Checkident Returns a report that indicates the current identity value and the expected identity value.
dbcc checkident (' table_name ') or dbcc checkident (' table_name ', reseed) If the current identity value of the table is less than the maximum identity value stored in the column, it is reset with the maximum value in the identity column. dbcc checkident (' table_name ', reseed, new_reseed_value) Current value set to new_reseed _value, the general New_reseed_value is the current largest ID value. If a row has not been inserted into the table since the table was created, the first row inserted after execution dbcc checkident uses new_reseed_value as the identity. Otherwise, the next inserted row will use new_reseed_value + 1. If the value of new_reseed_value is less than the maximum value in the identity column, subsequent references to the table will result in an error in the primary key violation