I have a table named employees with an identity column named id. Also,
last_name is a column in the table named employees. I created the employees
table and inserted 9 rows in it. If I do a select * from employees, the
output looks like this:
id last_name
1 a
2 b
3 c
4 d
5 e
6 f
7 g
8 h
9 i
Then I deleted rows where the id was 3, 4, 6, 7, and 8. So, if I do a
select * from employees, the output looks like this:
id last_name
1 a
2 b
5 e
9 i
So, my missing identity numbers are: 3, 4, 6, 7, and 8.
The code (that I just wrote) below prints to the screen these missing
identity numbers. If you can improve on it or have a better script, let me
know. Thanks.
2007-10-02 (first published: 2002-06-20)
15,449 reads