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

前端之家收集整理的这篇文章主要介绍了为数据库生成某个字段充填随机数的存储过程前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

<div class="codetitle"><a style="CURSOR: pointer" data="33089" class="copybut" id="copybut33089" onclick="doCopy('code33089')"> 代码如下:

<div class="codebody" id="code33089">
Declare @CurrentRecord int,@BeginNum int,@EndNum int,@TotalCount int,@Value int
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] = @Value where [IDColumnName] = @CurrentRecord
set @CurrentRecord=@CurrentRecord+1
End

猜你在找的MsSQL相关文章