通过游标逐行更改表中记录的随机值

declare my_cursor cursor scroll dynamic
 /**//*scroll表示可随意移动游标指        针(否则只能向前),dynamic表示可以读写游标(否则游标只读)*/
for
select views from dnt_topics
open my_cursor
declare @views int
fetch next from my_cursor into @views
while(@@fetch_status=0)
  begin
 update dnt_topics set views=@views+(cast(floor(rand()*5000) as int)) where current of my_cursor
fetch next from my_cursor into @views
  end
close my_cursor
deallocate my_cursor
posted @ 2008-10-06 12:45  痴人说梦  阅读(234)  评论(0编辑  收藏  举报