How to free space from the Tenant Media table?

Hi, I have 20GB of information from the Tenant Media table, I need help on how to free up space on that table. I deleted the images of all the products from the Items table and they are still visible in that table, there are even images that had been removed a long time ago. I am using Dynamics NAV 2018.


  • Options
    TallyHoTallyHo Member Posts: 396

    The only way I know how to do this:

    First you have to scan your database for used media type fields.
    (This can be automated using recrefs, or just decide what fields are needed to be kept in tenant media)

    Create a buffer table with only guid as primary key.
    Insert all MediaId guids that are used from all tables and media fields you pinpointed in previous step.

    F.i. while looping DocAtt:
    if DocAtt."Document Reference ID".hasvalue then begin
    UpgDocAttMediaId.Id := DocAtt."Document Reference ID".MediaId;

    The guids in UpgDocAttMediaId are the primary for
    TenantMedia: Record "Tenant Media";

    So finally, if not your TenantMedia is found in UpgDocAttMediaId,
    TenantMedia can be deleted.

    And theoretically, if no tenantmedia is found, the media field should be cleared.

    When migrating to SaaS you do want to clean up this table before uploading it all.
    Hopefully somebody here found a better way to do this, and is willing to share too🙂.

Sign In or Register to comment.