FIx sql and update script