使用SqlServer2005 随机数产生模拟数据 更新表
declare @gs int,@ge int
set @gs = -15
set @ge = -1
declare @id varchar(20)
declare cr_cursor cursor --1.定义游标
for select id from tabData where dt between '2013-11-18 12:00:00' and '2013-11-18 15:00:00'
open cr_cursor --2.打开游标
fetch From cr_cursor into @id --3.提取游标
while @@fetch_status=0
begin
update tabData set gs = cast(ceiling(rand() * (@ge - @gs) + @gs) as int) where id = @id
fetch next From cr_cursor into @id
end;
close cr_cursor --4.关闭游标
deallocate cr_cursor --5.释放游标