以下示例从表[tableName]中读取10条随机记录的SQL语句
1 Access
select top 10 * from [tableName] order by rnd(id)
select top 10 * from [tableName] where [cond] order by rnd(id)
注:id是自增长类型的主键
2 SQL Server
select Top 10 * From [tableName] order By NewID()
另外:还有种方法:先获取总记录数,然后取1~总数之间的随机数,rs.move,不过这种方法有点罗嗦,在此不推荐。