While trying to run a large script in SQL Server Express, I encountered this exception:
“There is insufficient system memory in resource pool ‘internal’ to run this query.”

The script was around 60 MB, enclosed in a single transaction.

In this case, adding some “GO” statements in the script resolved the issue and allowed the script to execute. Of course, after each “GO”, any variables being used have to be re-declared and initialized.