If you have turned on Audit logging in SharePoint 2007, you will wake up some day with a nasty surprise of a bloated SQL server database.  The data is all being stored in the AuditData table in the content database.

Luckily, there is an STSADM command for this, “stsadm -o trimauditlog”
After some research, the general consensus is to not truncate the table directly, although no specific reason is ever given except “Not Supported.”

As I always prefer to use a standard API, I found that you must do this command in very small chunks or else you could lock up your SQL server and effectively crash your SharePoint installation (found out the hard way).

I found 800,000 records to take approximately 15 minutes on a 2 Web Front end 1 Index Server, SQL Cluster type SharePoint farm.  To be safe, I wrote a PowerShell script to take care of these bite [...]