articles:

select random records from access

Here is a very simple way of selecting random records from an Access database:

SELECT TOP 5 * FROM [tableName] ORDER BY rnd(INT(NOW*id)-NOW*id)

The only prerequisite is that you have an AutoNumber Id column. It should also be noted that although this generates a random set of records, they are not truely random in a mathematical sense, but should be sufficiently random for most uses.

This method of selecting records also works in sql server, but you have to change rnd to rand.

Comments

There are no comments on this article yet, be the first to leave one

Post a comment

name:
(optional)

email:
(optional)

comment:

call us on 01344 762988