modify bugs in SQL script