尔冬橙

博客园 首页 新随笔 联系 订阅 管理

有些时候,我们希望同时更新表中的多条记录,但更新的值不一样。

declare @i int

declare @j int

declare @phone varchar(20)

set @j=1 select @i=count(*) from LatestLocation

DECLARE L_cursor CURSOR FOR SELECT Phone FROM LatestLocation

OPEN L_cursor

while @j<=@i

begin

FETCH NEXT FROM L_cursor into @phone update LatestLocation set LocationY = 32.009795 - 0.014887*RAND() * 0.7 where Phone=@phone

set @j=@j+1

end

CLOSE L_cursor

DEALLOCATE L_cursor

posted on 2014-08-11 22:45  尔冬橙  阅读(870)  评论(0编辑  收藏  举报