日期:2014-05-18  浏览次数:20503 次

【求助】求一条SQL语句
username password 
AAA 11111 
BBB 11111 
CCC 11111 
DDD 11111 
将passwoord列的初始值全部随机为某2个数之间的值,这张表的数据是大量的, 
请问怎么解决? 
谢谢

------解决方案--------------------
比如插入20000-50000的值:
create table test(username varchar(10),password int)
insert test select 'asdfj',null
insert test select 'asdfj',null
insert test select 'asdfj',null
insert test select 'asdfj',null
insert test select 'asdfj',null
insert test select 'asdfj',null
insert test select 'asdfj',null
insert test select 'asdfj',null
insert test select 'asdfj',null
insert test select 'asdfj',null

update test set password=cast((50000-20000)*rand(checksum(newid())) as int)+20000