Hi @Omid Omid
identity increment bug
Actually, it is not a bug. This is by design in SQL server. SQL Server guarantees that the next number generated will be unique and incremental, it does not guarantee it will be in sequence.
suddenly it jumps about 26943 instead 27. why?
There might be couple of potential causes:
- Rows were deleted.
- Identifiers were allocated in a transaction which wasn't committed.
- The database engine allocated potential identifiers as an internal performance tuning and that allocation was lost (unexpected server re-start, for example).
Besides, there could be more potential causes I'm not thinking of.
If you need a gapless column for query, then you could use ROW_NUMBER along with some calculation, like this:
SELECT ROW_NUMBER()OVER(ORDER BY id) * 27 + 17403 AS Gapless_id
FROM Your_Table
Best regards,
LiHong
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.