write sql to file