IF exists (select myxh from @x where myxh=@xh1) or @xh1<@min_xh or
@xh1 not in (select xh from #stu where grade='2001' and class=3 )
goto loop1
else
insert into @x values(@xh1)
set @i=@i-1
END
select * from @x
select * from #stu where xh in (select myxh from @x) and grade='2001' and class=3