Tag Archives: SQL

Reset Identity Seed


from StackOverflow

This is useful for resetting the identity column if you ever make a mistake by inserting duplicated rows and end up deleting one of them. My use-case was that this identity column needs to be in-sync with the other databases and it is used as foreign keys in some other tables.

Alternatively, you can turn it off:

SET IDENTITY_INSERT sometableWithIdentity ON

INSERT sometableWithIdentity (IdentityColumn, col2, col3, ...)
VALUES (AnIdentityValue, col2value, col3value, ...)

SET IDENTITY_INSERT sometableWithIdentity OFF