How to Clean The EPM Database using a SQL script

Version 15

    Verified Product Versions

    Endpoint Manager 9.6Endpoint Manager 2016.xEndpoint Manager 2017.xEndpoint Manager 2018.x



    The attached SQL Script is intended to help optimize the EPM database and improve the performance of processes that rely heavily on it, such as Inventory. Below details what specific portions of this script does.  Please make sure to stop the "LANDesk Inventory Server" and "LANDesk Scheduler" services before doing any direct work on the EPM database.  Also, as mentioned below, always take a full backup of your database before performing any modifications to the database.


    This script IS NOT officially supported by Ivanti. Ivanti is not responsible for any damages, direct or incidental, caused by running this script. RUN AT YOUR OWN RISK!

    ALWAYS take a FULL backup of your database before making any modifications to the database, including, but not limited to, running this SQL Script.


    What it does


    • Clears Patch History
    • Clears Auditing History
    • Clears EPS Logging History
    • Cleans unnecessary files from file information tables
    • Drops Temporary tables created by DA during vendor imports.
    • Rebuilds indexes
    • Runs CHECKDB
    • Creates a SQL checkpoint





    The below lines in the SQL script should be edited to better match your company's needs.


    SET @DaysToKeepPatchHistory = 90 --Change 90 to how many days of patching history you want

    SET @DaysToKeepAuditing = 90 --Change 90 to how many days of auditing history you want


    The value of 90 means the script will retain 90 days of the affected data (Patch history, auditing, EPS history). This should be changed to reflect your company's data retention and reporting needs/policies.