Create the stored procedure

The script spShrinkEventTable_install.sql creates a stored procedure which moves data from the EVENT table to a backup log table EVENT_BACKUP. If the EVENT_BACKUP table does not exist, it is created automatically.

The first line is "USE SafeGuard". If you have selected a different name for your SafeGuard Enterprise database, modify the name accordingly.

The stored procedure leaves the <n> latest events in the EVENT table and moves the rest of the events to the EVENT_BACKUP table. The number of events to be left in the EVENT table is specified by a parameter.

To execute the stored procedure, initiate the following command in SQL Server Management Studio (New Query):

exec spShrinkEventTable 1000

This command example moves all events except for the latest 1000 events.