sql - Insert specific random values into temp table -



sql - Insert specific random values into temp table -

i need create dummy info 1 of new tables in our database. getting values existing tables , creating new columns in values randomly chosen list of values.

my table structure:

id -- increment 1 personsid -- values different table status --need insert random values of illustration "waived" or "enrolled" statusdate -- need insert random datetime within past few months school --need insert random values of illustration "a", "b", "c", "d" changedby --need insert random username different table

can guide me regarding how insert random, specific values in table?

if want random values, basic look in sql rand(checksum(newid())). here ways might utilize this.

for id, assume have new table identity column. here illustration query:

insert newtable(personsid, status, statusdate, school, changedby) select personsid, (case when rand(checksum(newid())) < 0.5 'waived' else 'enrolled' end), cast(getdate() - 90 * rand(checksum(newid()))), (select top 1 col (select 'a' col union select 'b' union select 'c' union select 'd' ) t order rand(checksum(newid())) ) , (select top 1 username othertable ot order rand(checksum(newid())) ) persons;

sql sql-server random sql-insert

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -