Suppose we have a table
declare @Table1 table(id int)
insert into @Table1
select 1 union all select 2 union all select 3 union all select 4 union all
select 5 union all select 6 union all select 7 union all select 8
And another table as
declare @Table2 table(id int)
insert into @Table2
select 1 union all select 2 union all select 5 union all select 8
We need to find out the numbers that are missing in second table (@Table2)
Solution1: select id from @Table1 except select id from @Table2
Solution2: select id from @Table1 where id not in (select id from @Table2)
Output id
3
4
6
7