Problem Statement:
APS and MBO SQL databases contain a lot of data that may not always be needed after some time. Therefore, users often ask for scripts that enable them to remove all date created before a particular date to keep the database size within reason.
Solution:The attachments below contain SQL Scripts that can be used to clear necessary data prior to a specific date. This date is of course modifiable, and we recommend using extreme caution when applying these scripts, as the actions are irreversible. Please contact your IT support resources to ensure appropriate actions are being taken to avoid unwanted data loss when running these scripts. Please review the declarations of variables and make sure to switch them to match your given database information.
The scripts are divided in 2: a Legacy and Modern events clean up script. The Modern script is focused on clearing the data for 'modern' pipeline crude shipment, crude receipt, and Fill destination change events. The legacy script contains information on deleting all other event types from the ATORIONEvents tables.