例子1:
declare @a int
set @a=1
while @a<=要循环的次数
begin update table set Id=@a
@a=@a+1
end
例子2:
declare @month_tmp varchar(2);
declare @day_tmp varchar(2); set @month_tmp = '1'; set @day_tmp = '1'; while(@month_tmp < '13') begin while(@day_tmp < '30') begin select * from table1 where month=@month_tmp and day=@day_tmp set @day_tmp = @day_tmp + 1 end set @month_tmp = @month_tmp + 1 set @day_tmp = 1 |
Sql循环语句小例子!
最新推荐文章于 2024-04-12 16:50:10 发布