Skip to content

Instantly share code, notes, and snippets.

@kmlprtsng
Created October 8, 2013 21:03
Show Gist options
  • Save kmlprtsng/6891637 to your computer and use it in GitHub Desktop.
Save kmlprtsng/6891637 to your computer and use it in GitHub Desktop.
Add id manually in column with Identity and reset seed value
--http://www.sqlteam.com/article/how-to-insert-values-into-an-identity-column-in-sql-server
SET IDENTITY_INSERT IdentityTable ON
INSERT IdentityTable(TheIdentity, TheValue) VALUES (3, 'First Row')
SET IDENTITY_INSERT IdentityTable OFF
--Note that the next value will be whatever you reseed with + 1, so in this case I set it to 10 so that the next value will be 11.
--This SEED should get updated itself if any Id higher than the seed is used
DBCC CHECKIDENT (IdentityTable, RESEED, 10) --Reset seed value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment