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
In this stored procedure I am getting output as single table for every loop so I am getting multiple tables as output but I want all rows in a single table I think through union we can achieve but I do not know how to use.
1 Answer