Ok,
So you are selecting data from a local table, and finding something from a remote table?
How many records is the local query returning?
Now, you are scanning the local table, and then scanning the remote table for each record in the local table. This is very inefficient.
Also, do you have to do a LIKE on PARTNO with a percent sign surrounding it? The info you are looking for doesn't have the full partno? That is very inefficient also.
Anyway... what I would do it insert the results of the local query into a remote table... Then, run a single query on the back end that joins to this remote table. This way, there is only 1 call to the back end to do your big query and all the work happens on the server.
Or, if the result set from the local table is small, you can build the select like:
cSelect = [SELECT * FROM Whatever WHERE ]
SCAN
cSelect = cSelect + [PartNo LIKE '%]+cPartNo+[%' OR ]
ENDSCAN
if right(cSelect,2) = 2
cSelect = Left(cSelect, len(cSelect)-2)
endif
Now send that to the back end, so you are making one trip to the back end.
Does any of this make sense?
BOb