lcSql = [SELECT ] lcJoin = [] FOR lnFor = 1 TO FCOUNT([MasterTable]) lcFld = FIELD(lnFor,[MasterTable]) lcSql = lcSql + IIF(lnFor = 1, [],[,]) + [NVL(MasterTable.]+lcFld+[, TempTable.]+lcFld+[) AS lcFld] lcJoin = lcJoin + IIF(lnFor = 1, [],[ AND ]) + [MasterTable.]+lcFld+[ == TempTable.]+lcFld NEXT lcSql = lcSql + [ FROM MasterTable ]+; [FULL JOIN TempTable ON ]+lcJoin+; [ WHERE MasterTable.KeyFld IS NULL OR TempTable.KeyFld IS NULL]+; [ INTO CURSOR crsTest] &lcSql SELECT crsTest BROW NORMAL