Fixed sql fail