使用SQL语句逐条更新每条记录

时间:2014-08-12 00:27:13   收藏:0   阅读:290

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

使用SQL语句逐条更新每条记录,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!