例子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
转载请注明原文地址: https://ibbs.8miu.com/read-2232640.html