Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying random fields. How do I determine how many?

Status
Not open for further replies.

liamm

Technical User
Aug 12, 2002
102
0
0
GB
Hi,
I have the following code for a query

SELECT TOP 25 ID, Question, Answer
FROM RefresherQuestions
WHERE (((RefresherQuestions.[Plant Section ID])=2))
ORDER BY RND(ID);

What I would like is to have the facility for the end user to be prompted on How Many fields should be generated. At the moment the code displays 25 randomly selected fields.

If you can help, GREAT
If I can help, EVEN BETTER
 
Try this

SELECT TOP 25 ID, Question, Answer
FROM RefresherQuestions
WHERE [Plant Section ID])=2
ORDER BY newid()
 
Code:
CREATE PROCECURE GetQuestions
  @QuestionCount int
AS
  
  SET ROWCOUNT = @QuestionCount

  SELECT ID, Question, Answer
  FROM RefresherQuestions
  WHERE (((RefresherQuestions.[Plant Section ID])=2))
  ORDER BY RND(ID)

GO
You will have to prompt your user before calling the stored procedure and the pass the number of questions into the proc.

“I apologize for this long letter. I didn't have the time to make it any shorter” --Blaise Pascal
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top