SELECT contacts.contactid, contacts.companyid ; FROM contacts ; WHERE UPPER(contacts.lastname) = ?PADR(UPPER(loadfile.f),LEN(contacts.lastname)) ; INTO CURSOR contacts_found_cursorIf I change the SQL to the following it only takes 0.01 of a second to run.
SELECT contacts.contactid, contacts.companyid ; FROM contacts ; WHERE UPPER(contacts.lastname) = ?PADR(UPPER(loadfile.f),EVAL("LEN(contacts.lastname)"))The following also only takes 0.01 of a second to run.
cLastName = PADR(UPPER(loadfile.f),LEN(contacts.lastname)) SELECT contacts.contactid, contacts.companyid ; FROM contacts ; WHERE UPPER(contacts.lastname) = cLastNameIt appears that the first example is not being optimised but the second and third ones are. Any ideas as to why the first one isn't optimised? Could it be because the SQL sees the Contacts Table on both sides of the Where Clause?