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

有些时候,咱们但愿同时更新表中的多条记录,但更新的值不同。get

declare @i intio

declare @j inttest

declare @phone varchar(20)date

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

DECLARE L_cursor CURSOR FOR SELECT Phone FROM LatestLocationwhile

OPEN L_cursormail

while @j<=@ico

begintar

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

set @j=@j+1

end

CLOSE L_cursor

DEALLOCATE L_cursor

相关文章
相关标签/搜索