用break
declare @temptable table (title int,title2 int,title3 int)
declare @minbianma int,@bianma varchar(10),@looptimes int,@i int
set @looptimes=50
set @i=0
set @minbianma=5100
while @i < @looptimes
begin
set @bianma=@minbianma+1+@i
if @bianma =5102
begin
break
end
if 5121<=@bianma<=5132
begin
break
end
if 5138<=@bianma>=5143
begin
break
end
set @1=(select count(*) from table where id like @bianma+'%')
set @1=(select count(*) from table2 where id like @bianma+'%')
set @1=(select count(*) from table3 where id like @bianma+'%')
insert into @temptable
values (@1, @2, @3) set @i=@i+1
end
这样写好象行不通吧
begin
break
end
if @bianma >=5138and @bianma<=5143
begin
break
end