set ansi_warnings off; declare @IntezmenyId int, @TanevId int; declare @cursor cursor; set @cursor = cursor static for select i.ID as INTEZMENYID, t.ID as TANEVID from T_INTEZMENY i inner join T_TANEV t on t.C_INTEZMENYID = i.ID where i.TOROLT = 'F' and t.TOROLT = 'F' and t.C_AKTIV = 'T' order by 1, 2; truncate table T_ORARENDTELJES; open @cursor; fetch next from @cursor into @IntezmenyId, @TanevId; while(@@fetch_status = 0) begin print concat('Orarend: ', @IntezmenyId, ', ', @TanevId); exec dbo.uspGenerateTeljesOrarend @IntezmenyId, @TanevId; fetch next from @cursor into @IntezmenyId, @TanevId; end close @cursor; go alter index all on T_ORARENDTELJES rebuild; go set ansi_warnings on;