array parameter

What I want to do is...suppose Its a table containing 50 questions and I have to select 30 questions out of it randomly. So in the select statement I have to use a where clause which will use a array parameter . that array will hold all the 30 serial numbers of the questions and depending on the serial numbers the questions will be selected from the table.If there is any Random fuction in Sql for random number generation and for using an array as the parameter of the where clause.Please let me know, I need help very quickly.
[530 byte] By [shuvo] at [2007-11-18 20:22:45]
# 1 Re: array parameter
I would tend to populate a temporary table with the 30 random numbers and return a join rather than trying to do it your way...
TheCPUWizard at 2007-11-9 13:37:44 >
# 2 Re: array parameter
No it is different...you have to randomly select rows from the Question bank table..the questions are number 1.2.3.4--so I have to retrieve 30 of them and form a dataset in .net Platform
shuvo at 2007-11-9 13:38:44 >
# 3 Re: array parameter
What I want to do is...suppose Its a table containing 50 questions and I have to select 30 questions out of it randomly. So in the select statement I have to use a where clause which will use a array parameter . that array will hold all the 30 serial numbers of the questions and depending on the serial numbers the questions will be selected from the table.If there is any Random fuction in Sql for random number generation and for using an array as the parameter of the where clause.Please let me know, I need help very quickly
shuvo at 2007-11-9 13:39:42 >
# 4 Re: array parameter
Please do not cross post. This thread is being reported to the moderator for merging...
TheCPUWizard at 2007-11-9 13:40:47 >
# 5 Re: array parameter
as TheCPUWizard said :
create a temp table with random values then use a join or where ...in

declare @rand table(num tinyint not null)
declare @n tinyint
set @n=0
while @n<30
begin
Insert into @rand values(rand()*51)
set @n=@n+1
End
select * from questions where questionID in (select num from @rand)
hspc at 2007-11-9 13:41:45 >
# 6 Re: array parameter
[moved & merged threads]
Andy Tacker at 2007-11-9 13:42:44 >
# 7 Re: array parameter
I needed advise from someone with vb.net experience,thats why I posted it in that section.Anyway I need to make this query in generating a DataSet object...will vb.net support this code in things like

dim objds as dataset()
dim conn as string
dim sqlstr as string

sqlstr= (all the sql code about temporary table that is given above)

dim objda as new oledbadapter(sqlstr,strconn)
objda.fill(objds)
shuvo at 2007-11-9 13:43:47 >
# 8 Re: array parameter
Originally posted by shuvo
...will vb.net support this code in things like

dim objds as dataset()
dim conn as string
dim sqlstr as string

sqlstr= (all the sql code about temporary table that is given above)

dim objda as new oledbadapter(sqlstr,strconn)
objda.fill(objds)
I think the answer is yes
why don't you just try it ?:)
hspc at 2007-11-9 13:44:50 >