Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 changing order of columns in select statement

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-11-22 : 07:45:35
David writes "Hello SQL Team.

I have a table that holds multiple choice questions for an examination application.
i.e columns as such
question
A
B
C
D

At present I extract a set of questions and use ASP(vbscript) to
reorder the answers A,B,C,D so that each time they are presented to the end user the answers are in a different order.
I thought it would be more efficient to do this extra processing on the sql server instead of the Web Server.

Basically what I'm trying to acheive through SQL is to select 50 questions from my table that would follow this sort of pattern

first test - select question,a,b,c,d
second test -select question,d,c,b,a
third test - select,c,a,d,b

I thought of using a UDF and dynamic SQL to change the select statement each time - not sure

Hope someone can help

Cheers

David
..................................."

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-11-22 : 07:53:01
Just use this query
Select a,b,c,d from yourTable

Then in your ASP Page, according to test values, show the records in the specified format

first test - rs("a"),rs("b"),rs("c"),rs("d")
second test rs("d"),rs("c"),rs("b"),rs("a")

etc

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2005-11-22 : 09:56:17
Have a look at the "order by NEWID()" phrase to see if it solves what you seem to need...ie random presentation of questions....going sideways instead of down is just a presentation issue and can be tackled as a seperate matter.
Go to Top of Page
   

- Advertisement -