读书人

【】求一条SQL语句

发布时间: 2012-03-30 17:32:09 作者: rapoo

【求助】求一条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

读书人网 >SQL Server

热点推荐