write sql into tmp file (works with big sql's)