--随机取500条
select top 500 * from 表 order by newid()

解决方案 »

  1.   

    SET ROWCOUNT 500
    select * from (select top 500 * from 表 where 编号 not in (select 编号 from 上个月的数据) order by newid()) tem
    union all
    select * from 上个月的数据
      

  2.   

    select top 400 * into #a from tablename where 条件=本月
    select top 100 * into #b from tablename where 条件=上月select * from #a 
    union all
    select * from #bdrop table #a
    drop table #b规定比率
      

  3.   

    select top 400 * into #a from tablename where 条件=本月 order by newid()
    select top 100 * into #b from tablename where 条件=上月 order by newid()select * from #a 
    union all
    select * from #bdrop table #a
    drop table #b规定比率