How to fix Error 4984 on Windows Server 2025 / Windows 11

Troubleshooting Guide: Error 4984 – Vardecimal Storage Format Mismatch in ALTER TABLE SWITCH

Why This Error Happens

This error occurs because SQL Server requires the source and target tables in a partition SWITCH operation to have identical physical storage formats, and the “vardecimal storage format” setting is enabled on one table but not the other. This mismatch typically happens when tables are created at different times under different default settings, or when a database-level or table-level configuration was changed after one of the tables was already created. Since SWITCH is a metadata-only operation, SQL Server cannot reconcile differing row storage formats on the fly, so it blocks the operation entirely.

Step-by-Step Resolution Guide

Step 1: Verify Current Vardecimal Storage Settings

  • Open SQL Server Management Studio (SSMS) and connect to the target instance.
  • Run the following query to check the current state on both tables:
  EXEC sp_tableoption 'YourSourceTable', 'vardecimal storage format';
  EXEC sp_tableoption 'YourTargetTable', 'vardecimal storage format';
  • Note which table has the setting enabled (1) and which has it disabled (0).

Step 2: Align the Vardecimal Storage Format on Both Tables

  • Identify the table with the mismatched setting (usually the newly created or newly loaded table).
  • Run the following command to enable or disable the setting to match the other table:
  EXEC sp_tableoption 'YourMismatchedTable', 'vardecimal storage format', '1';
  • Note: If using SQL Server 2025 on Windows Server 2025, ensure the database compatibility level supports this setting, as vardecimal storage format is a legacy feature retained for backward compatibility.

Step 3: Rebuild Indexes to Apply the Format Change

  • After changing the vardecimal storage format option, the change does not take effect until you rebuild the table’s indexes.
  • Run the following command to force the conversion:
  ALTER INDEX ALL ON YourMismatchedTable REBUILD;
  • If the table has no clustered index, you may need to rebuild the heap by creating and dropping a clustered index, or use ALTER TABLE ... REBUILD.

Step 4: Re-run the ALTER TABLE SWITCH Statement

  • Once both tables report the same vardecimal storage format value, re-attempt the original partition switch operation.
  • Example:
  ALTER TABLE YourSourceTable SWITCH TO YourTargetTable PARTITION x;
  • Confirm the operation completes without raising Error 4984.

Alternative or Verification Steps

  • To verify the fix, query sys.tables joined with sys.partitions or re-run sp_tableoption on both tables to confirm the vardecimal storage format values now match (both should return the same 0 or 1 value).
  • As an alternative, if rebuilding indexes on a large table is too costly in production, consider creating a new staging table with matching settings via SELECT INTO or CREATE TABLE AS SELECT, then switching into that table instead of altering the existing one.