need query to random update field with 0,1,2,3 or 4

R

Rob

Hi, I need to update a field with a random number 0 1 2 3 or 4 in order to
test a report. Can anyone set me up with a query for this? There is no
criteria to update from, it should update all records in the table.

Thanks,
Robbie
 
J

John W. Vinson

Hi, I need to update a field with a random number 0 1 2 3 or 4 in order to
test a report. Can anyone set me up with a query for this? There is no
criteria to update from, it should update all records in the table.

Thanks,
Robbie

UPDATE yourtable
SET yourtable.fieldname = Int(5*Rnd([ID]));

where ID is some non-negative numeric field within the table.

John W. Vinson [MVP]
 
R

Rob

Thanks!

John W. Vinson said:
Hi, I need to update a field with a random number 0 1 2 3 or 4 in order to
test a report. Can anyone set me up with a query for this? There is no
criteria to update from, it should update all records in the table.

Thanks,
Robbie

UPDATE yourtable
SET yourtable.fieldname = Int(5*Rnd([ID]));

where ID is some non-negative numeric field within the table.

John W. Vinson [MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top