ALTER PROC [dbo].[Usp_SelectQuestion]
@NoOfQuestion int
AS
BEGIN
Declare @CNT int
Declare @test int
Declare @x int
Declare @y int
set @x = 1;
set @y = 1;
set @CNT=(Select Count(*) from (select Distinct(setno)from onlin) AS A)
set @test=@NoOfQuestion/@CNT
while (@x <= @CNT)
begin
select top (@test) * from onlin where setno = @x order by NEWID()
set @x = @x + 1
end
END
在这个存储过程中,我将每个循环的输出作为单个表,因此我将多个表作为输出,但我希望单个表中的所有行我认为通过联合我们可以实现,但我不知道如何使用。