Hi, I have just noticed a table of ours which has big jump in identity numbers. It only has 240k rows, with a standard INT identity column. From about row 140k, the identity number jumps a massive 1375554757 and increments from there for the rest of the rows. The table doesn't get many deletions or updates, mainly inserts.
I used a LAG function to compare adjacent IDs and pull out differences of over 1000, like this.
SELECT r.PrevCodeId, r.CodeId, r.CodeId - r.PrevCodeId AS Diff FROM ( SELECT c.CodeId, LAG(c.CodeId, 1) OVER (ORDER BY c.CodeId) AS PrevCodeId FROM sv_360_Codes c ) AS r WHERE r.CodeId - r.PrevCodeId > 1000 ORDER BY r.CodeId;
The result in question looks like this:
PrevCodeId CodeId Diff 189756 1375744513 1375554757
The jump may have happened when we migrated from our previous hosting provider to Azure, though I'm not sure why it would have caused it to reseed to such a huge number.
What is the best advice currently about how to address this? There are 2 table that rely on that ID as a foreign key. I could feasably write some code to re-assign IDs after reseeding, but I'm wondering if there's an easier way, or some tools that can help? How do people usually address this issue?