First create the function "dbo.fn_generate_numbers_v2", which will generate the defined sequence of numbers.
By joining this function with our table, we can able to retrieve the list of missing sequence numbers or identity numbers.
declare @table table (id int)
declare @max int
insert into @table values (1),(2),(3),(4),(5),(7),(9),(10),(15)
select @max = max(id) from @table
select n.RowNum from dbo.fn_generate_numbers_v2 (@max) n
left outer join @table t1 on n.RowNum = t1.id
where t1.id is null
Regards,
Vignesh Arulmani