语法格式:
while 条件
begin
.......
end
declare @num int=100 while @num > 99 begin update SDetail set SName='达文西-屌' where SScore>99 set @num=@num-10 end
本文介绍了一种使用SQL的while循环来更新数据库中特定记录的方法。通过设置条件和更新语句,可以有效地修改满足条件的数据,例如将分数高于99的记录的SName字段更新为‘达文西-屌’。此技巧适用于需要批量更新相似条件记录的场景。
语法格式:
while 条件
begin
.......
end
declare @num int=100 while @num > 99 begin update SDetail set SName='达文西-屌' where SScore>99 set @num=@num-10 end
转载于:https://www.cnblogs.com/qq1981684148/p/6915017.html

被折叠的 条评论
为什么被折叠?