Fix sql failure