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]

# 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 >

# 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 >

# 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 >
