Jul 13
and (number - @pStartValue) % @pIncrement = 0
--===== Find the "gap ranges" -- This assumes that gaps include any whole number greater than 0 SELECT GapStart = (SELECT ISNULL(MAX(b.MyID),0)+1 FROM #MyTest b WHERE b.MyID < a.MyID), GapEnd = MyID - 1 FROM #MyTest a WHERE a.MyID NOT IN (SELECT MyID + 1 FROM #MyTest)
WHERE a.MyID NOT IN (SELECT MyID + 1 FROM #MyTest) and a.MyID > 1