Sql循环语句小例子!

    技术2022-05-20  71

    例子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

    最新回复(0)