/*
寻找断点
*/
if object_id('test1') is not null
drop table test1
go
create table test1(t1 int, t2 varchar(10));
insert into test1
select 2,'b' union all
select 3,'c' union all
select 4,'d' union all
select 6,'e' union all
select 7,'f' ;
go
select case
when not exists (select * from test1 where t1=1 ) then 1
else(
select min(t1)+1 from test1 o1
where not exists(select t1 from test1 o2 where o2.t1=o1.t1+1 )) end;