没有比ORDER BY NEWID()更简单的方法了。愉快的登山者       ⊙
◢◣◢◣◢◣

解决方案 »

  1.   

    select top 10 * from 表 order by newid()
      

  2.   

    试了用rand()没有做到比newid()好一点!
      

  3.   

    select top 10 * from 表 order by newid()这样为什么不行?
      

  4.   

    create proc P_RandRecord @tablename varchar(25)
     as
     exec('select identity(int,1,1) as idd,* into #t from '+@tablename)
     select * into #t1 from #t where 1=2
      declare @n int
      set @n=0
      while @n<>10
       begin
        insert into #t1 select * from #t where idd=(cast(rand()*100) as int)
        @n=@n+1
       end 
      select distinct top 10 * from #t1 
      

  5.   

    select top 10 * from 表 order by newid()这样为什么不行?
    top 方法中,,top 10 后面不能直接用*或者为空,必须加详细列名