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

Troubleshooting Guide: SQL Server Error 9825 – DECOMPRESS Builtin Failed

Why This Error Happens

Error 9825 occurs when SQL Server’s DECOMPRESS function encounters data that is not in a valid compressed format, often because the data was corrupted during storage or transmission, or because it was never actually compressed using the corresponding COMPRESS function. This can also happen if the binary/varbinary column was altered, truncated, or manipulated by an external process outside of SQL Server’s compression algorithm (GZIP). Additionally, on Windows Server 2025 and Windows 11 environments, this can surface due to mismatched collation settings or data corruption introduced during cross-platform migrations.

Step-by-Step Resolution Guide

Step 1: Verify the Source Data Format

  • Check that the data being passed to DECOMPRESS was originally compressed using the native COMPRESS() function in SQL Server 2025.
  • Run a validation query to inspect the binary header: SELECT TOP 10 ColumnName, DATALENGTH(ColumnName) FROM YourTable WHERE ColumnName IS NOT NULL;
  • Confirm the data wasn’t manually edited or exported/imported via a tool that could alter byte-order or strip GZIP headers.

Step 2: Check for Data Corruption or Truncation

  • Run DBCC CHECKDB('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; to rule out page-level corruption.
  • Inspect the column definition to ensure it is VARBINARY(MAX) and not truncated by a smaller data type (e.g., VARBINARY(8000) or IMAGE).
  • If using Always Encrypted or TDE, verify the encryption/decryption keys are correctly mapped, as key mismatches can corrupt binary payloads.

Step 3: Isolate the Query and Test DECOMPRESS Manually

  • Isolate the exact row causing the failure using a binary search approach (e.g., WHERE ID BETWEEN X AND Y).
  • Test the function manually: SELECT DECOMPRESS(ColumnName) FROM YourTable WHERE ID = [ProblemID];
  • If the error persists only on specific rows, flag those rows as corrupted and restore them from a known good backup.

Step 4: Update SQL Server 2025 Cumulative Updates

  • Navigate to the SQL Server Configuration Manager and verify the current build version via SELECT @@VERSION;.
  • Download and install the latest Cumulative Update (CU) from the Microsoft Update Catalog, as early 2025 builds had a documented bug with GZIP stream handling on Windows Server 2025.
  • Restart the SQL Server service via services.msc or net stop MSSQLSERVER && net start MSSQLSERVER.

Alternative or Verification Steps

  • Verification: After applying the fix, re-run the original failing query. If successful, execute SELECT DATALENGTH(DECOMPRESS(ColumnName)) to confirm the output length matches the expected uncompressed size.
  • Alternative: If the data is confirmed corrupted and no backup exists, restore the specific table or row from the most recent .bak file using RESTORE DATABASE... WITH PARTIAL to recover only the necessary table schema and data.