"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" SQL TIP: REPLACE RELATIONAL COMMANDS WITH SQL """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" PRODUCT : R:BASE VERSION : 3.1 CATEGORY : SQL SUBCATEGORY : RELATIONAL JOBS """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Replace programs, complex reports, and relational commands with SQL to achieve maximum performance. SQL is the optimum choice for a network where creating new tables and changing the database structure can be difficult. SQL is a relational language so it works well with a good relational design. Use SQL to replace relational commands (INTERSECT, SUBTRACT, and UNION), and stop making temporary tables. Use SELECT with DECLARE CURSOR, CREATE VIEW, or INSERT in place of relational commands like INTERSECT, SUBTRACT, UNION, or PROJECT. You get the same results without the overhead of a temporary table. Use a Cursor Instead of PROJECT """"""""""""""""""""""""""""""" Get rid of the PROJECT & DELETE DUPLICATES in this R:BASE for DOS code: PROJECT temptab FROM transact + USING keycol WHERE... ORDER BY... BUILD KEY FOR keycol IN temptab DELETE DUPLICATES FROM temptab SET POINTER #1 e1 FOR temptab *( WHILE loop here to process data) REMOVE temptab Use this faster R:BASE 3.1 code: DECLARE c1 CURSOR FOR + SELECT DISTINCT keycol FROM transact *( WHILE loop here to process data) Use SELECT Instead of INTERSECT """"""""""""""""""""""""""""""" Replace INTERSECT with an inner join: SELECT t1.collist, t2.collist FROM tbl1 t1, + tbl2 t2 WHERE (t1.linkcol = t2.linkcol) Replace SUBTRACT with a sub-SELECT: SELECT collist FROM tbl2 WHERE + NOT EXISTS (SELECT linkcol FROM + table1 WHERE table1.linkcol = tbl2.linkcol) Replace UNION with outer joins: SELECT t1.collist, t2.collist FROM tbl1 t1, + tbl2 t2 WHERE (t1.linkcol = t2.linkcol) + UNION ALL SELECT t1.collist, constants + FROM tbl1 t1 WHERE NOT EXISTS + (SELECT linkcol FROM tbl2 WHERE + tbl2.linkcol = t1.linkcol) + UNION ALL SELECT t2.collist, constants + FROM tbl2 t2 WHERE NOT EXISTS + (SELECT linkcol FROM tbl1 WHERE + tbl1.linkcol = t2.linkcol) All examples assume there are no null values in the linking columns.