为数据库生成某个字段充填随机数的存储过程
(编辑:jimmy 日期: 2024/11/15 浏览:3 次 )
复制代码 代码如下:
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
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
下一篇:SqlServer 执行计划及Sql查询优化初探