Reseeding Identity values

  • BASAVARAJU R

    SSC-Addicted

    Points: 416

    Comments posted to this topic are about the item Reseeding Identity values

  • JRoughgarden

    Ten Centuries

    Points: 1119

    I believe this will produce errors on tables with existing data.

    From BOL on DBCC CHECKIDENT:

    DBCC CHECKIDENT ( 'table_name', RESEED, new_reseed_value )

    Current identity value is set to the new_reseed_value. If no rows have been inserted to the table since it was created, the first row inserted after you run DBCC CHECKIDENT uses new_reseed_value as the identity. Otherwise, the next row inserted uses new_reseed_value + the current increment value.

    If the table is not empty, setting the identity value to a number less than the maximum value in the identity column can result in one of the following conditions:

    If a PRIMARY KEY or UNIQUE constraint exists on the identity column, error message 2627 will be generated on later insert operations into the table because the generated identity value will conflict with existing values.

    If a PRIMARY KEY or UNIQUE constraint does not exist, later insert operations will result in duplicate identity values.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply