Call Savance Workplace Call Us: (248) 478-2555

Support Suite

User Login



 

Main

Knowledgebase: EIOBoard
Deleting Old Status History for On-Prem Servers - SQL
Posted by Sam Lynn on 19 October 2022 02:59 PM

This document only pertains to customer with On-Premise EIOBoard servers

 

Database Script for Deleting Status History

This script can be run as a query against your EIOBoard database. Please backup your database before

running any scripts on your Database. This will delete all status history of a user past the 'Days' provided.

You can run this as a SQL Task as a Daily, Weekly, or Monthly task to automate the process as well

 

DECLARE @Days INT

--Enter Days as a negative number to delete historical data and positive numbers to delete future statuses. 
--'Days' is the desired days in the past or future you wish to delete the history for.
--Please note if you run this script with 0 'Days' it will delete all Future Status and Status History.
--For example -365 will delete all status history/future status 1 year ago for all users
SET @Days = 0;

--PRINT '>>> Deleting FutureStatus'
DELETE FutureStatus WHERE DateUpdated < DATEADD(DAY, @Days, GETDATE());

--PRINT '>>> Deleting StatusHistory'
DELETE StatusHistory WHERE DateUpdated < DATEADD(DAY, @Days, GETDATE());