Fixed SQL export