Perhaps the following example should help.
-- the table that will have rows numbered from 1 to 1000
select top 1000 identity(int,1,1) as id into #X from syscolumns
-- the table with missing values
select top 200 identity(int,1,2) as id into #Y from syscolumns
-- select * from #x
-- select * from #y
select #x.id, #y.id from #x
left outer join #y on #x.id = #y.id
where #y.id is null
You should have a temp table like #x, which will have all the values (including max value of the row). In above example, I am assuming the range is from 1 to 1000.