select sourcetable, copy structure to temptable copy all to temptable where UPPER(substr(thefield))="S"As you can see this would copy a subset of the source table to temptable. If sourcetable had an index, the records copied to temptable would also be ordered, so it might not be necessary to pass the index paramenter to the exe program. Maybe you could just pass the temptable name to the exe.