sql dumpings logic