When restoring a database: there is insufficient system memory to run this query

Also, since you have backups of all the old databases – does it makes sense to leave the companies laying around? Can you delete the older companies or move them to seperate server?