>>Get your Jobs and Users into local cursors and then join with them locally.
>
>The Sql Server table 'Jobs' has 43,000 rows in it and I need to join them with a local cursor that has about 8 rows in it to find the 8 matching records in 'Jobs' based on a lookup field.
If the records are some try
lcMatCodeList = ""
SELECT lcCsrMtlRecords
SCAN
lcMatCodeList = lcMatCodeList + TRANSFORM(mat_code) + ","
ENDSCAN
lcMatCodeList = LEFT(lcMatCodeList, LEN(lcMatCodeList)-1)
TEXT TO lcSql TEXTMERGE NOSHOW
SELECT Users.email
FROM Users
INNER JOIN Jobs On Jobs.quoted_by = Users.emp_num AND Jobs.job_num IN(<<m.lcMatCodeList>>)
WHERE qty_recd <> before_qty_rec
ORDER BY 1
GROUP BY 1
ENDTEXT
lnRes = SQLEXEC(lnSqlHandle, lcSql, "crsTemp")
BROWSE NORMAL
_______________________________________________________________
Testing displays the presence, not the absence of bugs.
If a software application has to be designed, it has to be designed correctly!
_______________________________________________________________
Vladimir Zografski
Systems Analyst