sql export + cleanup