This FAQ outlines a way of retrieving a random set of records for audit or other prurposes.
The method requires that the table has a numerical field on which to operate
the sql is very simple
select top X from yourtable
order by rnd(numericalfield)
This will give the x records and will be different everytime it is run.
If you need to ensure that you don't get any of the records from last time it was run then the keyfield(s) of the records could additionally be placed in a temporary table (e.g. tblauditedlasttime)and excluded from the search
e.g.
select top X from yourtable
order by rnd(numericalfield)
where keyfield not in (select keyfield from tblauditedlasttime)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.