Created
October 8, 2013 21:03
-
-
Save kmlprtsng/6891637 to your computer and use it in GitHub Desktop.
Add id manually in column with Identity and reset seed value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--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