Home >Database >Mysql Tutorial >为数据库生成某个字段充填随机数的存储过程

为数据库生成某个字段充填随机数的存储过程

WBOY
WBOYOriginal
2016-06-07 18:00:25980browse

为数据库生成某个字段充填随机数

代码如下:
Declare @CurrentRecord int,@BeginNum int, @EndNum int, @TotalCount int,@Value int
set @BeginNum=0
set @EndNum=500
set @TotalCount=80
set @CurrentRecord=1
While @CurrentRecordBegin
set @Value= @BeginNum+(@EndNum - @BeginNum)*rand()
update [tableName] set [columnName] = @Value where [IDColumnName] = @CurrentRecord
set @CurrentRecord=@CurrentRecord+1
End
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn