Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
SELECT TOP 1 T1.Field1+1 AS FirstAvailableNumber
FROM @TheTable AS T1 JOIN @TheTable AS T2
ON T2.Field1 > T1.Field1
GROUP BY T1.Field1
HAVING MIN(T2.Field1)-T1.Field1 > 1
SELECT TOP 1 T1.Field1+1 FirstAvailableNumber
FROM @TheTable AS T1 LEFT JOIN @TheTable AS T2
ON T2.Field1 = T1.Field1+1
WHERE T2.Field1 IS NULL
SELECT MIN(a.Field1) + 1
FROM MyTable a
LEFT JOIN MyTable b ON b.Field1 = a.Field1 + 1
WHERE b.Field1 IS NULL