How to safely remove sql server tables that belong to deleted eSpaces

How to safely remove sql server tables that belong to deleted eSpaces

If you are sure you don't need the data that exist in entities belonging to deleted eSpaces, you may safely drop the tables in Sql Server.

You should download the Performance Tuning for OutSystems Applications Technical Note at

In this technical note, you'll find two scripts that will help you do what you want. Search for Drop views from deleted eSpaces and Drop tables from deleted eSpaces inside the tech note.

For each of these scripts:
1 - copy the script and paste it in sql server analyzer;
2 - set results to Text (menu item Query / Results in Text);
3 - execute the query

You'll get result like:
/* QAEntities(deleted0) */ DROP VIEW
/* QAEntities(deleted0) */ DROP VIEW

Between comments is presented the eSpace 'owner', followed by the sql statement to drop the object (table or view). You may copy the pretended results, paste it back in the execution pane and execute it.

Before executing it, please be very careful to check that all drop statements are correct. Also a database backup is advised.
Hi, just wondered if there's a more up to date version? Didn't really want to run SQL that was written 8 years ago on our v7 database!
Hi Iain,

In the technical note you'll see 2 versions of the scripts. You'll need to run the ones labeled "For Hub Server versions after 3.0...".
Again, make sure you do a database backup before you do this.

Tiago Simões
Kudos to Tiago, for still being alive and kicking (and available to answer) over 9 years after the original post! :-D

You rock,

Brilliant Tiago, thanks a lot for that! Miguel - spot on!

Cheers, Iain