Microsoft
Software
Hardware
Network
Question : Using rand() to generate data
I am trying to generate test data. I have one table that has a list of dates, another that has a list of residents. I want to generate a metric that is 1 80% of the time, and 0 the other 20%. Presumably, a random generator function needs to be employed.
Here's what I have:
SELECT D.ActualDay, R.RESIDENT_ID, 1 AS 'Metric'
FROM DIM_DATE AS D, DIM_RESIDENT AS R
Which generates my data except my metric is always 1. I did try using rand() and got a random number in the metric field, but it was the same number repeated over and over. I want a stored procedure, which I can run that will populate a table having fields day, resident, metric using the dates from DIM_DATE and the residents from DIM_RESIDENT.
Answer : Using rand() to generate data
RAND(
CAST( NEWID() AS varbinary )
)
Random Solutions
SQL Connection error
Kerberos authentication 'sometimes' not working - XP related problem(?)
How can I check a dynamic row of checkboxes if value exists so I enter the row into a db?
What is the easiest (cost effective) way of connecting two or more offices/sites?
new features in windows 2003 than windows 2000
mysql upgrade 4.1 to 5.1
No hard drive is recognized
Read XML through oracle view and ordered output
Update Query SQL 2008
how to exclude double