Hi Nadya,
1) The tables you are creatin are quite large: For RI for one year more than 1 million records.
2) Try to put result table on local drive and see what difference it makes.
3) Instead of calculating period and UserGrp for each record create cursor with 51 possible combination and than cross join it with resault of your select
HTH
>Hi everybody,
>
>I have a quite simple program for pre-populating a table. For RI it has 28152 iterations, for MA ~236000. For some reason, it works really slow (1min.56 sec. for RI, 27 min. for MA). I suspect server's problem, but our Network Administrator tells me, that server is ok. I tried switching order between scan...endscan and for...next. Once this program executes really fast, but then again worked very slow. Could you please tell, is something wrong with the code?
>How can I speed up this program?
>
> < snip >
>Thanks in advance.
--sb--