Sample Header Ad - 728x90

Determine Available Blocks of Contiguous Ids

0 votes
1 answer
192 views
We have a SQL Server table that has an int autoincrement primary key column on it. The table's primary key space is fragmented. For example, ids 1 through 10 are in use but then ids 11 through 100,000 are not in use. Ids 1,000,000 through 1,100,000 are in use but ids 1,100,000 through 50,000,000 are not in use. I am trying to figure out any and all such available range of ids. Once the ranges are determined, then we may reseed the primary key column to start at the beginning of the widest range. Any tool or utility or SQL script out there for determining such available ranges?
Asked by Manny Siddiqui (11 rep)
Sep 23, 2021, 06:13 PM
Last activity: Jun 22, 2025, 08:09 PM