Updated SQL script