{"title":"Estimate compressed data size in your Business Central online tenant","url":"https://jonas-paprotka.de/docs/dev-itpro/administration/cloud-migration-estimate-compressed-data-size/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/administration/cloud-migration-estimate-compressed-data-size, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/administration/cloud-migration-estimate-compressed-data-size","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Estimate compressed data size for Business Central online before cloud migration by using SQL Server compression estimates for your source tables.","date":"2026-11-17","meta":{"topic":"how-to"},"outline":[{"level":1,"title":"Estimate compressed data size in your Business Central online tenant","slug":"estimate-compressed-data-size-in-your-business-central-online-tenant","at":0,"chars":3587},{"level":2,"title":"Next steps","slug":"next-steps","at":3318,"chars":269}],"text":"# Estimate compressed data size in your Business Central online tenant\nIn the online version of Business Central, data is compressed using the SQL Server data compression feature. As a consequence, the data size in your on-premises database might not match the data size when migrated to the Business Central service.\nCurrently, all tables in the online version of Business Central are compressed with CompressionType set to Page.\nTo evaluate whether a table is a good candidate to compress, you can use the stored procedure sp_estimate_data_compression_savings in SQL Server. See https://learn.microsoft.com/sql/relational-databases/system-stored-procedures/sp-estimate-data-compression-savings-transact-sql.\n> NOTE\n> The stored procedure sp_estimate_data_compression_savings fails if the table has columns with `&` in the name.\nIf you want to estimate the compressed size of all or some tables in your database, you can create and, if needed, modify the following stored procedure:\n```sql\nCREATE PROCEDURE dbo.estimate_page_compressed_table_sizes\nAS\nBEGIN\n    SET NOCOUNT ON;\n\n    DECLARE @table_name sysname;\n\n    CREATE TABLE #compressed_table_report (\n        table_name sysname,\n        schema_name nvarchar(max),\n        index_id int,\n        partition_number int,\n        size_with_current_compression_setting bigint,\n        size_with_requested_compression_setting bigint,\n        sample_size_with_current_compression_setting bigint,\n        sample_size_with_requested_compression_setting bigint\n    );\n\n    DECLARE tables_cur CURSOR FOR\n    SELECT name\n    FROM sys.tables\n    WHERE schema_id = SCHEMA_ID('dbo');\n\n    OPEN tables_cur;\n\n    FETCH NEXT FROM tables_cur INTO @table_name;\n\n    WHILE @@FETCH_STATUS = 0\n    BEGIN\n        INSERT INTO #compressed_table_report\n        EXEC sp_estimate_data_compression_savings\n            @schema_name = 'dbo',\n            @object_name = @table_name,\n            @index_id = NULL,\n            @partition_number = NULL,\n            @data_compression = 'PAGE';\n\n        FETCH NEXT FROM tables_cur INTO @table_name;\n    END;\n\n    CLOSE tables_cur;\n    DEALLOCATE tables_cur;\n\n    SELECT\n        table_name,\n        SUM(size_with_current_compression_setting)\n            AS size_with_current_compression_setting_KB,\n        SUM(size_with_requested_compression_setting)\n            AS size_with_requested_compression_setting_KB,\n        SUM(\n            size_with_current_compression_setting -\n            size_with_requested_compression_setting\n        ) AS size_saving_KB\n    FROM #compressed_table_report\n    GROUP BY table_name\n    ORDER BY size_saving_KB DESC;\n\n    DROP TABLE #compressed_table_report;\nEND;\nGO\n```\nTo run the stored procedure, execute the following commands:\n```sql\nUSE [TenantDatabase] -- Replace TenantDatabase with your tenant database name.\nGO\n\nEXEC dbo.estimate_page_compressed_table_sizes\nGO\n```\nThe stored procedure sp_estimate_data_compression_savings fails if the table has columns with `&` in the name. With the following query, you can find the table names that should be excluded in definition of the stored procedure dbo.estimate_page_compressed_table_sizes.\n```sql\nSELECT t.name AS table_name\n     , col.name AS column_name\n  FROM sys.columns col\n INNER JOIN sys.tables t ON col.object_id = t.object_id\n WHERE col.name LIKE '%&%'\n```\n## Next steps\n Understand data compression in Business Central<using-sql-partitioning-and-compression>\n Check prerequisites<cloud-migration-prerequisites>\n Optimizing cloud migration performance<migration-optimize-replication>\n Run data migration setup<migration-setup>"}