Reputation: 5369
I want to distribute 116 records to users via SQL but what is the best way to do this randomly, so for example if its worked out that everyone gets 5 rows how do i randomly insert records with a datetime stamp which is different every hour?
So for user 1, i insert every 10 mins, but for user to i want something different, maybe every 5 mins?
I was thinking if i randomly get a number between 5-10 and then use that as my interval? Then populate a temporary table called, [USED]
and then do a NOT EXISTS query and make sure my random interval isnt in there.
The idea is to make it appear as though everyone has created there records, so i dont want it to look like a batch insert. It needs to look like a human has done this.
Upvotes: 2
Views: 101
Reputation: 4737
That does not sound very "random" as it would look fake to have 5 records on each user. This is a better approach I think:
INSERT INTO your_table (User_ID,Date_Col)
VALUES ((SELECT TOP 1 ID FROM your_user_table ORDER BY NEWID()),
DATEADD(second, rand()*36000, DATEADD(day, rand()*120, getdate()))
Upvotes: 1