为数据库生成某个字段充填随机数的存储过程
程序员文章站
2023-12-09 16:08:33
复制代码 代码如下:declare @currentrecord int,@beginnum int, @endnum int, @totalcount int,@valu...
复制代码 代码如下:
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
推荐阅读