edwardspiggy
New Member
I want help from you to create a query. I am new in software career and i am trying to developing a KBC Type Quiz Game for Windows Mobile Application. For That i want try to fetch random records from database and if one record is appear at one time after that record will not appear again. I use This query \[code\]"SELECT TOP 1 * FROM Quiz ORDER BY NEWID()"\[/code\] but records are repeat. I try to create a Store Procedure also which is given below\[code\]DECLARE @counter int, @randno int, @uBound int, @lBound int SELECT @uBound = Max(Id) FROM Quiz SELECT @lBound = Min(Id) FROM Quiz SELECT @randno = Round(((@uBound - @lBound) * Rand() + @lBound), 0) SET @Counter = 0 WHILE @counter = 0 BEGIN IF EXISTS(SELECT Id FROM Quiz WHERE Id = @randno) BEGIN SET NOCOUNT OFF SELECT * FROM Quiz WHERE Id = @randno SET @counter = 1 END ELSE BEGIN SELECT @randno = Round(((@uBound - @lBound -1 ) * Rand() + @lBound), 0) END END\[/code\]but i can't get success. My Table contain this fields Que, Ans1, Ans2, Ans3, TrueAns. Please Help me for this problem. And i want to also create a web-service which return all the records