Q&A about the site for students, teachers, and linguists wanting to discuss the finer points of the Italian language
CREATE TABLE #table( ID int ); INSERT INTO #table VALUES (4), (5), (10); SELECT TOP 1 t1.Id+1 as ID FROM #table t1 WHERE NOT EXISTS(SELECT * FROM #table t2 WHERE t2.Id = t1.Id + 1) ORDER BY t1.Id DROP TABLE #table;