declare @mincnt int
declare @maxcnt int
select @mincnt=min(id) from table1
select @maxcnt=max(id) from table1
while @mincnt<=@maxcnt
begin
if Exists (select * from table1 where id not in (@mincnt))
begin
insert into table1(id) values(@mincnt)
end
set @mincnt = @mincnt +1
end