Should be fixed now @Aurora International LLC. Looks like it was over-batching. Interesting that this has never crashed the database before when I run the same code as a manual script but crashes within a task. Guess there is extra overhead? Not too sure, either way I have reduced the batch sizes and it seemed to have resolved the issue.