Pages

Monday, 20 January 2014

How to read random records from a table



SELECT top 10  *
FROM CbzInventory
Order by newid()


SELECT top 10 *
FROM CbzInventory
WHERE InvIntLocation=7
ORDER BY NEWID()


select top (@intTopWeight)   q.QuesDesc,o.choice1,o.choice2,o.choice3,o.Answer
from Question q join Options o
on  q.QuesID=o.QuesId and q.UserLevelID=1   join ExamWeightage e on e.TopicID=q.TopicID where e.TopicId=1  Order by newid()

No comments:

Post a Comment