Como recupero registros aleatórios de uma consulta?
Autor: Joe Foster
Cole a função abaixo em um módulo padrão.
'************ Início do código ***********
'Código cortesia de
'Joe Foster
Function Randomizer () As Integer
Static AlreadyDone As Integer
If AlreadyDone = False Then Randomize : AlreadyDone = True
Randomizer = 0
End Function
'************ Final do código *************
Como pegar 100 perguntas selecionadas aleatoriamente:
SELECT TOP 100 MinhaTabela.* from MinhaTabela
WHERE Randomizer() = 0
ORDER BY Rnd(IsNull(MinhaTabela.Pergunta) * 0 + 1)