这是博主用在一个项目上的源码片断,无论是速度、均衡性,还是随机度都非常好,当然这更不可能抽到重复记录了。
一、在MS SQL Server 2000中生成随机记录的最好办法:
with tk_query do
begin
Close;
sql.clear;
sql.Add('select top '+inttostr(st_count)+' tk.ID,标准答案 from 题库表 tk');
sql.Add('where pid is null and tk.题型='+quotedstr(tx)+' and tk.知识点='+quotedstr(zsd));
sql.add('and tk.难易度='+quotedstr(nyd)+' and tk.课程号='+quotedstr(kcdm)+' order by newid()');
Open;
end;
注:关键就是...[ 查看全文 ]