It seems this happens because your project contains duplicate or incomplete rows in the "AI_SQLScript" table. I'm not sure how your project reached this corrupt state.
Can you please send us your AIP (project file) to support at advancedinstaller dot com, so we can investigate it and try to find the problem? Also, can you please try to isolate this error in a test case scenario? Maybe you can find a working version of your project and starting from that working project state try to find out a pattern (test case) which always replicates this error. This would be very useful for us so we can isolate and investigate this issue.