Fix some sql errors.