Fix some error in sql file

The file have some bugs and I try to fix then.