web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Table 700 "Error Message" is taking up 12 GB of space

(9) ShareShare
ReportReport
Posted on by 69
So i have a question about this particular table no. 700 called "Error Message". My client has been live since 2022 and so far this Error Message table has 43,364,923 records with a total size of 12,423,256 KB = 12 GB. The largest table in terms of records and size in the database currently. 
 
Is there a way to delete the entries from this table? There is no reason why we need error messages from more than 6 months or 1 year ago. It is taking quite a lot of unnecessary space (also especially when we copy our Production to lower environments). We have also looked into Retention Policy to clean this table up but this table ID is not available in the retention policy. 
 
I have the same question (0)
  • Suggested answer
    Sohail Ahmed Profile Picture
    11,136 Super User 2025 Season 2 on at
    That table grows fast because BC logs every posting/validation error there. Since it’s not covered by retention policy, the only way is to clear it yourself  either with a small AL routine to delete old records on a schedule (SaaS) or a SQL cleanup if you’re on-prem. Keeping just the last few months is usually enough for troubleshooting.
     
     
    ✅ Mark this as the verified answer if helpful.
  • Suggested answer
    Sohail Ahmed Profile Picture
    11,136 Super User 2025 Season 2 on at
    Here’s a simple pseudo code you (or your partner/dev) can adapt for cleaning up table 700 "Error Message":
     
    procedure CleanupErrorMessages()
    var
        ErrorMsg: Record "Error Message";
        CutoffDate: Date;
    begin
        // Keep only last 6 months
        CutoffDate := CalcDate('-6M', Today);
    
        if ErrorMsg.FindSet() then
            repeat
                if ErrorMsg."Created DateTime" < CutoffDate then
                    ErrorMsg.Delete();
            until ErrorMsg.Next() = 0;
    end;
    
     
     
    Create a Job Queue setup so this cleanup runs automatically every month
     
     
     
    ✅ Mark this as the verified answer if helpful.
  • Suggested answer
    Sumit Singh Profile Picture
    10,079 on at
    Hi Asfand, 
     
    Please refer below links which might help you:- 
     
     
     
  • Suggested answer
    YUN ZHU Profile Picture
    95,331 Super User 2025 Season 2 on at
    Hi, or you can customize a simple cleanup codeunit and set it in the Job Queue to clean up once a month.
     
    Thanks
    ZHU
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    20,363 Super User 2025 Season 2 on at
    Agree you can create small codeunit which will run in every month
  • Suggested answer
    Satish Srivastava Profile Picture
    242 on at
    codeunit 50100 "Error Message Management"
    {
        Caption = 'Error Message Management';
        UsageCategory = Tasks;
        procedure CleanupErrorMessages(MonthsToKeep: Integer := 6)
        var
            ErrorMsg: Record "Error Message";
            CutoffDate: Date;
            RecordsDeleted: Integer;
        begin
            // Calculate cutoff date (default = last 6 months)
            CutoffDate := CalcDate(StrSubstNo('-%1M', MonthsToKeep), Today);
            // Apply filter instead of looping for performance
            ErrorMsg.SetRange("Created DateTime", 0DT, CreateDateTime(CutoffDate, 235959T));
            if ErrorMsg.FindSet() then begin
                RecordsDeleted := ErrorMsg.Count();
                ErrorMsg.DeleteAll();
                // Optional log/notification
                Message('%1 old error message(s) deleted (older than %2).', RecordsDeleted, CutoffDate);
            end;
        end;
        [TryFunction]
        procedure SafeCleanupErrorMessages(MonthsToKeep: Integer := 6)
        begin
            CleanupErrorMessages(MonthsToKeep);
        end;
    }
     
  • Suggested answer
    Ramesh Kumar Profile Picture
    7,527 Super User 2025 Season 2 on at
    I hope below article can help you
     
     
    Thanks
    Ramesh
     
    If this was helpful, please check the "Does this answer your question?" box and mark it as verified.
  • Suggested answer
    Kamal Khakhkhar Profile Picture
    1,274 on at
    hii there ,
    as per suggested by other members you can apply the code . along with that apply FindSet(true) will do a LockTable() before finding rows, which is an advantage if you plan to update all the rows you are finding.
     
     
    If you found your answer mark it answered.
     
    Thank You 
    Kamal Khakhkhar

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,143

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,694 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,067 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans