delete from invoice where 0 delete from invoicedet where id not in (select id from invoice); delete from invoice_ruc where id not in (select id from invoice); delete from invoice_cliente where id not in (select id from invoice); delete from invoice_address where id not in (select id from invoice); delete from accountcus where inicial=0 and trim(idinvoice)!="" and idinvoice not in (select id from invoice) ; delete from accountcuscuota where idaccountcus not in (select id from accountcus); delete from accountcusaux where idaccountcus not in (select id from accountcus); delete from auxcxc where idaccountcuscuota not in (select id from accountcuscuota); delete from detareceiv where idaccountcuscuota not in (select id from accountcuscuota); delete from receiv where id not in (select id from detareceiv); delete from detallechequesposf where idaccountcuscuota not in (select id from accountcuscuota); delete from chequesposf where id not in (select id from detallechequesposf); drop table loader_h; drop table loader_d; delete from po where 0; delete from podet where id not in (select id from po); delete from poaux where id not in (select id from po); delete from accountsup where trim(idpo)!="" and idpo not in (select id from po) ; delete from accountsupcuota where idaccountsup not in (select id from accountsup); delete from accountsupaux where idaccountsup not in (select id from accountsup); delete from auxcxp where idaccountsupcuota not in (select id from accountsupcuota); delete from detapay where idaccountsupcuota not in (select id from accountsupcuota); delete from pay where id not in (select id from detapay); delete from payaux where id not in (select id from detapay);