Answer the question
In order to leave comments, you need to log in
How to implement sequential numeric ID generation in MS SQL?
I stumbled upon the problem of sudden Identity Seed jumps: when the database server is restarted, the value can increase by 1000. Which ultimately leads to the presence of something like this in the table: records are numbered from 1, 2, 3 ... then 1001, 1002 and so on.
I read what's what; apparently, you should not build your logic around Identity. How to implement a consistent increment with integrity support, if this is a business need? Only the option with the addition of one more field comes to mind ... the logic of which needs to be just written.
Answer the question
In order to leave comments, you need to log in
because this mechanism is to guarantee uniqueness, not to guarantee non-breaking sequence. everything is fine.
ordering business logic for such things is not correct.
if you need sequential number generation is really important - SELECT MAX
value can increase by 1000Either you have replication on this database, or failover is configured incorrectly (without rolling back uncommitted transactions).
with the addition of one more field ... the logic of which needs to be just writtenYes, in the trigger, either calculate the missing number, or create a separate table of unused numbers and take from it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question