Appsense Events not deleting
Problem: Appsense database is growing over time. The EVENTS table is huge.
Solution: (at the time of writing this article) Appsense do not have an event management / retention period. It simply records all events indefinitely. Run the following script on the database server.
—–Begin SQL script, select and copy into a text file and rename it to .sql extension; run on SQL server that holds AppSense database
— Set the following to the database that this script operates on USE [DatabaseName]
— This represents the number of days to preserve events for
— i.e. ‘7’ will delete events older than one week DECLARE @ageOfEvents INT SET @ageOfEvents = 7
— Delete the events
DECLARE @eventCount INT
DECLARE @oldestEventTime DATETIME
SET @oldestEventTime = DATEADD (DD, -@ageOfEvents, GETUTCDATE()) PRINT N’Deleting events older than ‘ + CONVERT(NVARCHAR(32),
@oldestEventTime)
EXEC Event_DeleteFromTime NULL, @oldestEventTime, 0, @eventCount OUTPUT PRINT CONVERT(NVARCHAR(12), @eventCount) + N’ events deleted’
—–End SQL script