A表: 有三条记录
B表: 有六条记录
   要求用嵌套循环连接显示出18条记录。哪位给一个例子。 为什么下面不行,只能循环一次Select @N_Min=min(ID) from #tmp7 where 1=1 
       Select @N_Max=max(ID) from #tmp7 where 1=1        Select @N_Min2=min(ID) from #tmp8 where 1=1 
       Select @N_Max2=max(ID) from #tmp8 where 1=1 
       Select @N_Min3=min(ID) from #tmp8 where 1=1        while  @N_Min<=@N_Max 
       begin 
          Select top 1 @V_SL= SL from #tmp7 where ID=@N_Min
          while  @N_Min2<=@N_Max2 
          begin 
             Select top 1 @V_SL2= SL from #tmp8 where ID=@N_Min2 
             set @V_LSHM=@V_SL+@V_SL2;             insert into #tmp9(SL)values(@V_LSHM)
             set @N_Min2=@N_Min2+1;
             continue
          end         set @N_Min2=@N_Min3
        set @N_Min=@N_Min+1;
        continue
      end