CREATE TABLE #table( ID int ); INSERT INTO #table VAL...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Genealogy and Family History Meta

Q&A about the site for expert genealogists and people interested in genealogy or family history

CREATE TABLE #table(

    ID  int 
);


INSERT INTO #table VALUES
(4),
(5),
(6),
(7),
(8),
(9),
(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;

Enter Parameters

Options:
Switch to main site
loading Hold tight while we fetch your results