I have an auto increment identity column in sql server, but I want to specify a specific value for one of the rows. So the number scheme would be as follows:
1 ...,
2....,
999 - for the reserved entry,
3....,
n....
How can I do this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need to use
IDENTITY_INSERT:You also have to use the explicit field list in the
INSERTstatement, and are limited to one activeIDENTITY_INSERTper session.This will also reset the seed value to be whatever you inserted if it’s higher than the current ID value.
You can get around this too by using
DBCC CHECKIDENTbut it’ll be a big pain to manage.