Fix to sql error