可以先做一个含15000 - 20000的临时表, 然后外连接.
create table #seq_num(id int)
-- 临时表
declare @seq int
set
@seq = 15000
while @seq < 20001
begin
insert into #seq_num values(@seq)
-- 临时表赋值
set
@seq = @seq + 1
end
select
a.*
from
#seq_num a left join YourTB b
on a.id = b.id
where
b.id is null
drop table #seq_num