Fixing stupid sql script