Fix sql errors.