How to set two column in SQL Server database as auto increment int with increment seed 100 ?
Share
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 can only have one identity column per table, however, there are some ideas and workarounds here
Simulation using a Derived Computed Column
If both “identity” columns are synchronized with each other, or the second identity can be derived from the first using a formula, then a Computed Column might be applicable, e.g. if the second
identityis offset by a constant from the actual Identity column:Where
RealIdentityis the actual / originalIDENTITYcolumn.Computed Column derived off Identity SqlFiddle example here
Using an Independent Sequence
Another alternative would be to use an independent Sequence (Sql2012 and Later)
Sequence SqlFiddle example here