I use an SQL task to produce a result set which I store in a package variable.
It works fine to access the result set in a script task by first casting it to a ADODB.Recordset, and then enumerating it and accessing the rows in the given order.
But is there a simple and clean way to randomly access the result set In other words to repeatedly select a random row from it
One thought I had was to convert the result set to some sort of array which can be randomly indexed. But I didn't find out how... I'm not interested in creating an array by looping through the whole result set and inserting the rows one by one into an array. So is there some other better way

Random access in a result set
leekitswee
I don't know of one (which doesn't mean there isn't one!!!)
-Jamie
Dave Zarlengo
May i know more about this transformation component in SSIS
what is that actually
How it work and can i have some sample code btw may i know is the randomly samples rows record will not duplicate
regards
terence chua
Sean Te.
That's right Duane.
Terence, there is a data-flow transformation component in SSIS that randomly samples rows for you.
-Jamie
Dan Rooney
osama.jasser
Again, you could probably do this in a script component. Pick a record at random (I dare say .net provides a way of picking a number at random) and output that record as many times as you want. Is that what you want to do
This would have to be an asynchronous component. Your script source is an asynchronous component so perhaps you could combine the two into one!
-Jamie
Selva kumar
Seah Chen Khoon
Thanks Jamie... That's a good idea to use the source script component, because that's actually what I want to do... Generate arbitrary many random rows. But then there is a limitation with the row sampler: it can only produce at most as many rows as it gets as input. If it only gets 100 rows it can at most produce 100 sample rows... =(
Hrm... Is there some other way to go
leiaduva
Hi Samuel,
did you find any solution on your problem already
actually i also face similiar requirement. i need to create a customer contact list basic on yesterday transaction record. to just say thank to them. but my management dun want 100% of customer be selected, them just want around 80% and not 80% from begining or end of transaction. them want it randomly.
then write all the record into a .txt or .dat file. to pass to the other module to send out sms.
i able to use rnd() function to get the sequence randomly, and i also try to avoid using loop to get all record.
regards
terence
John Stewien
I am looking for
either (1) a clean way to do the conversion from a record set into some kind of array without having to loop through the complete record set.
or (2) a straightforward way to make random selections from a record set.
Maybe there is no better way than the "looping through"-solution
Endre Oláh
Yeah, that makes alot more sense (I thought it was a strange requirement).
The same still stands though. Within the script component read the recordset into an internal storage mechanism and pick as many rows as you want at random.
-Jamie
Ziad Adada
Terence,
Will the row sampler component not work for you
-Jamie
macky100
What I want to do is to generate arbitrary many rows where each row is randomly selected (and therefore most probably unique). So preferably not a bunch of identical rows.
Hope I managed to explain it a bit more! ! =)
Fiona Coen
Just an idea...not a recommendation!
-Jamie
Washoe Tech
Hi Jamie,
may i know what is row sampler actually i'm new in .NET normally i only code in vb6. and i not advance user. cos the program is all just in house using only so many component also dun know how to use. did you have any sample code
terence