Database Cleanup (SQL Server)

Tags: #<Tag:0x00007fe1d9e56380>

Good afternoon.
I have a large amount of processing and, in result, a large amount of data that need to be deleted.
Does anyone have a database cleanup script for SQL Server?

Have a nice day.

TRUNCATE TABLE [HangFire].[AggregatedCounter]
TRUNCATE TABLE [HangFire].[Counter]
TRUNCATE TABLE [HangFire].[JobParameter]
TRUNCATE TABLE [HangFire].[JobQueue]
TRUNCATE TABLE [HangFire].[List]
TRUNCATE TABLE [HangFire].[State]
DELETE FROM [HangFire].[Job]
DBCC CHECKIDENT ('[HangFire].[Job]', reseed, 0)
UPDATE [HangFire].[Hash] SET Value = 1 WHERE Field = 'LastJobId'
3 Likes

Doesnt Hangfire clean up automatically?

2 Likes

Is it possible to add this to SQL Job?
but not for all jobs, only for Successful jobs. (I want to remove them physically)
And What do I need to do to change the above script based on that?
… One more thing, I will add Shrink Db also on the above script :slight_smile: