Troubleshooting Guide: SQL Server Error 4995 – Vardecimal Storage Format Not Available in System Databases
Why This Error Happens
This error occurs because the sp_db_vardecimal_storage_format procedure is being executed against a protected system database such as master, model, msdb, or tempdb. SQL Server intentionally restricts vardecimal storage format changes to user-defined databases, as system databases rely on a fixed, internal storage structure to maintain engine stability. Attempting to enable this legacy storage feature on a system database is blocked at the engine level and is not a permissions or corruption issue, but a hard architectural limitation.
Step-by-Step Resolution Guide
Step 1: Identify the Target Database Context
- Check the exact database name referenced in the error message (
%.*ls) to confirm it is indeed a system database. - Run
SELECT name, database_id FROM sys.databases;in SQL Server Management Studio (SSMS) to cross-reference system vs. user databases. - Confirm you did not accidentally run the script while connected to
masterinstead of your intended user database.
Step 2: Correct the Database Context Before Re-running the Command
- Open a new query window in SSMS and explicitly switch context using
USE [YourUserDatabase];before executing the procedure. - Re-run the command:
EXEC sp_db_vardecimal_storage_format 'YourUserDatabase', 'ON'; - Avoid running maintenance or storage-format scripts inside
master,model,msdb, ortempdbentirely.
Step 3: Audit Automation Scripts and Deployment Pipelines
- Review any PowerShell, DACPAC, or SSDT deployment scripts running on Windows Server 2025 that may loop through
sys.databasesand apply this setting to all databases, including system ones. - Add a filter condition such as
WHERE database_id > 4to exclude system databases (master,tempdb,model,msdb) from the loop logic. - Update any scheduled SQL Agent Jobs to explicitly target only intended user databases.
Step 4: Consider Modern Alternatives (Since Vardecimal Is Deprecated)
- Since SQL Server 2016+ (including SQL Server 2025), Vardecimal storage format is a legacy feature superseded by Row/Page Compression.
- On your user database, use
ALTER TABLE YourTable REBUILD WITH (DATA_COMPRESSION = ROW);instead for better storage efficiency and native engine support.
Alternative or Verification Steps
- Verify the Fix: Run
EXEC sp_db_vardecimal_storage_format 'YourUserDatabase', 'STATUS';to confirm the setting applies successfully without throwing Error 4995. - Alternative Solution: If vardecimal format is not strictly required, skip it entirely and implement
DATA_COMPRESSION = PAGEon the specific table, which achieves similar storage savings and is fully supported in Windows Server 2025 environments without the system database restriction.