Fixed SQL script