Missing user ids

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

;WITH Missing (missnum, maxid)
AS
(
 SELECT 0 AS missnum, (select max(id) from Users)
 UNION ALL
 SELECT missnum + 1, maxid FROM Missing
 WHERE missnum < maxid
)
SELECT missnum
FROM Missing
LEFT OUTER JOIN Users u on u.id = Missing.missnum
WHERE u.id is NULL
ORDER BY missnum ASC
OPTION (MAXRECURSION 0);

Enter Parameters

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