Fixing sql scripts