关键字“order”附近的语法不正确。 SQL

时间:2013-02-25 16:25:01

标签: sql sql-server

 (select top 1 percent A from B order by newid())

我想从表B中获取随机记录

1 个答案:

答案 0 :(得分:2)

像这样使用......

select * from B where A in 
 (select top 1 percent A from B order by newid())

OR

select top 1 percent A from B order by newid()

每次都会给你随机的行......

编辑:

Selecting Rows Randomly from a Large Table