zl程序教程

您现在的位置是:首页 >  数据库

当前栏目

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

数据库存储 过程 生成 某个 随机数
2023-06-13 09:14:18 时间
复制代码代码如下:

Declare@CurrentRecordint,@BeginNumint,@EndNumint,@TotalCountint,@Valueint
set@BeginNum=0
set@EndNum=500
set@TotalCount=80
set@CurrentRecord=1
While@CurrentRecord<=@TotalCount
Begin
set@Value=@BeginNum+(@EndNum-@BeginNum)*rand()
update[tableName]set[columnName]=@Valuewhere[IDColumnName]=@CurrentRecord
set@CurrentRecord=@CurrentRecord+1
End