If all you're wanting to do is UNION the data, then why do you need to put it into the database at all? Does the data need to be kept in the database on the new server permanently?
Seems like query DB on old server, query data on new server, use system.dataset.appendDataset()
to perform a union.
Otherwise, if you can use a third party application, then @pturmel's free Integration Tool Kit Module has many tools to do this type of thing in an expression rather than script, including UNION
and JOIN