>>To optimeze this, you need an index on ALLTRIM(RTE_NO), which is not advicabe, an index key must ALWAYS give a fixed length, which alltrim() does not give! A better solution is an index on ADDBS(RTE_NO,10) (adjust 10 if necessary), and this change in the select:
>>Select DISTINCT TIME from RZStop where ADDBS(RTE_NO,10) = lcRteNo ...
>
>You meant PADR() right? :-)
Yes, I ment PADR(), I wrote the message when I was in a hurry, I had to leave to pick up at my son!