游标的使用
时间:2014-08-26 15:09:36
收藏:0
阅读:219
把一张表的 每行数据的 一个字段的值进行随机
declare @tid int
declare topic_cur cursor for
select tid
from bbs_topics
open topic_cur
fetch next from topic_cur into @tid
while (@@fetch_status=0)
begin
UPDATE [dbo].[bbs_topics] SET iconid=CEILING(rand()*15) WHERE tid=@tid
fetch next from topic_cur into @tid
end
close topic_cur
deallocate topic_cur
原文:http://www.cnblogs.com/zhuangke668/p/3937250.html
评论(0)