SQL题库系统疑问

来源:百度知道 编辑:UC知道 时间:2024/05/10 08:57:16
最近学校组织数据库大赛,想做个题库系统,目前处于构思中,我问题是,如何让电脑随机抽取表中的一部分题目自动生成一份试卷??最好举个例子。。。谢谢

--随机找5条记录出来
declare @table table (id int,t varchar(1))
insert into @table
select 1,'a' union all
select 2,'b' union all
select 3,'c' union all
select 4,'d' union all
select 5,'e' union all
select 6,'f' union all
select 7,'g' union all
select 8,'h' union all
select 9,'i' union all
select 10,'j'
select top 5 * from @table order by newid()

用存储过程实现吧
如果一张表还可以用普通SQL解决
多张表的话就麻烦了
用过程解决好