I want to generate random questions from a table in sql server
i would like to use stored procedure whose input parameter will be integer that comes from web page(.aspx).
Below is the query to generate 10 random questions.
can i store the records in a temp table or array in sql server (i doubt if it is available) from where i can display them on a .aspx page using sqldata adapter in ASP.NET 2.0(VS 2005). Is there a better way to do?
Any guidance will be of great help to me
thanx
i would like to use stored procedure whose input parameter will be integer that comes from web page(.aspx).
Below is the query to generate 10 random questions.
can i store the records in a temp table or array in sql server (i doubt if it is available) from where i can display them on a .aspx page using sqldata adapter in ASP.NET 2.0(VS 2005). Is there a better way to do?
Any guidance will be of great help to me
thanx
Code:
DECLARE @intFlag INT DECLARE @random INT DECLARE @upper INT DECLARE @lower INT SET @intFlag = 1 set @lower=1 set @upper=100 WHILE (@intFlag <=10) BEGIN select @random=Round(((@upper-@lower-1))*RAND()+@lower,0) PRINT @random select * from science where ques_no=@random SET @intFlag = @intFlag + 1 END GO
Comment