Altering an Identity value on a existing table

  • if there are no rows present:

    DBCC CHECKIDENT (yourtablename, RESEED, 0)

    from the books online:

    DBCC CHECKIDENT ('table_name', RESEED, new_reseed_value)The 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 executing DBCC CHECKIDENT will use new_reseed_value as the identity. Otherwise, the next row inserted will use new_reseed_value + 1. If the value of new_reseed_value is less than the maximum value in the identity column, error message 2627 will be generated on subsequent references to the table
  • Another method:

    If the table isn't referenced by a foreign key constraint, you could TRUNCATE the table to reset the identitiy seed.

    Greg

    Greg

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

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