fixed sql script