oqueck (Flexera Software) asked a question.
0_TeslaPO (Flexera Software)There is a stored procedure ComplianceHistoryPurgeByDate that can be used for that. Please note, deletion might take significant amount of time depending on the size of the database, usage patterns, etc, so special consideration should be taken to choosing time when to run it. Of course, database backup must be taken before running it.Expand Post
ChrisG (Flexera Software)To preserve formatting, the solution to this forum post has been moved to this article: https://community.flexera.com/s/article/History-table-deletion-scripts-Solution-to-Forum-Post
Expand Post
Does deleting from ComplianceHistory also delete from ComplianceHistory_MT and ComplianceHistoryLimited_MT? We have much older data (3 years older) in ComplianceHistoryLimited_MT than ComplianceHistory_MT so I was wondering if there are database triggers on the ComplianceHistory View to clean both tables or should we run two scripts to clean the tables separately?
Thank you
Expand Post
ChrisG (Flexera Software)The short answer is yes: deleting from ComplianceHistory will delete from ComplianceHistory_MT and ComplianceHistoryLimited_MT.
ComplianceHistory itself is a view. In some compliance databases (depending on which versions of FlexNet Manager Suite have been installed in the past), you will find an "INSTEAD OF DELETE" trigger defined on this view which will delete records from the dbo.ComplianceHistory_MT and dbo.ComplianceHistoryLimited_MT tables which underlie the view.Expand Post
Hi Chris,
those Scripts seem to be amazing work. Sadly I can not find those documents in the Flexera Community anymore. Did they get removed? In case you still have a version of them, could you please republish them? That would be really helpfull😊
Best regards
Thies
Expand Post
ChrisG (Flexera Software)Could you elaborate on what documents you are looking for? (I don't think anything I have said in this thread refers to "documents in the Flexera Community" - am I missing something?)
Expand Post

Hello Oliver,
Deleting compliance computer records could take days and eventually cause locks if other activities happen (inventory import).
One approach is to use the script above and schedule a SQL server agent that will run every day from 10:00 AM to 5:00 PM (typically out of the inventory import time). Will select the top 5 million records... deleting by batches of 50K, with a commit every 50K records, to avoid a growth in log files. This is the first attached document.
Another approach that is way more efficient (extremely fast) is attached in the second script: this approach makes sense if the cleanup must be massive and impact potentially several billions of records. The approach is the following:
- Determine which ComplianceHistoryID corresponds to “3 month ago”. This ID will allow filters with way better performance.
- Export all “to be conserved” ComplianceHistory records:
- Less than 3 month old (old)
- More than three month old
- Related to contracts, purchases and Licenses.
- Truncate the ComplianceHistory Database (which will reset the complianceHstoryIDs)
- Re-import all conserved records.
- DROP the “To Be Conserved” History records temp table.
The interest of the scriptare the following
- It "reads" the ComplianceHistory_MT table columns (schema has varied over time) before "constructing" the queries based on the table schema. The script applies to any version of FNMS.
- The proportion of interesting records is very often way smaller than records to delete. Keeping the db and truncating it is more efficient than creating an empty one feeding it with records, dropping the big table and renaming the new table. There a triggers, indexes, constraints (to be renamed) that are making this option complex
- ComplianceHistoryID are reset with a truncate.
and you get for free an FNMS Inventory Computer cleanup script
Expand Post
To preserve formatting, the solution to this forum post has been moved to this article: https://community.flexera.com/s/article/History-table-deletion-scripts-Solution-to-Forum-Post