TRY:while @find=1
    begin
     /*保证iValue位于iStart和iEnd之间*/
     set @iValue = CONVERT(INT,RAND(datepart(millisecond,getdate())) * (@iEnd - @iStart + 1) + @iStart)/*  产生随机数*/
     select  @q_no=q_no from #mtemp where mid=@iValue
     print @q_no
     select  @already=count(*) from s_temptable where  (q_type=@q_type 
          and q_no=@q_no  and s_xh=@xh)
     if @already=0   set @find=0         
    end