MSDyn365FO. Truncate a table.

Now when storage capacity report is available you may want to clean up some data. One of the top one’s to grow out of control is document attachment history. You have standard batch job for the clean up, but if you have millions of records, it may take too long because that batch deletes only 50000 in a time.

Using custom script you can delete them in no time!

public static void main(Args _args)
{

    ttsbegin;
    new SqlDataDictionaryPermission(methodstr(SqlDataDictionary, tableTruncate)).assert();        
    new SqlDataDictionary().tableTruncate(tableNum(DocuHistory), false);
        CodeAccessPermission::revertAssert();
  
  ttscommit;
}

Leave a comment