Ich würde nicht Verwenden Sie dies, um "fehlende" IDs aufzufüllen, aber das sollte funktionieren:
Insert Into t (id)
Select Coalesce( Min(t.id) + 1, 0 )
From t
Left Join t As t2 On ( t2.id = t.id + 1 )
Where t2.id Is Null
Holen Sie sich alle id s wobei id + 1 existiert nicht (Left Join ) und fügen Sie Min(id)+1 ein oder 0 falls nicht verfügbar.