This is really straight forward. The documented way to delete Database mail history in SQL server is to use the following two stored procedures:
Great. But what happens when apparently billions of emails are stored in here taking up several hundred gigabytes in
msdb, and even the process of trying to clear only 100 days worth of email takes hours or days?
I don't want any history and I don't want to wait until I'm a senior citizen to clear the list of e-mail history. How do I truncate this history in one quick transaction?
So far my efforts at using the built in procedures have been futile - growing
msdb to terabytes in size and sitting "executing" for hours on end. Any attempt to cancel it results in the entire transaction being rolled back. It so far hasn't even been possible to count the number of emails that exist in the history - it's that bad.