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

Troubleshooting Guide: Error 304 in Microsoft SQL Server 2025

Why This Error Happens

Error 304 occurs when a value supplied for an index creation option or statistics configuration parameter (such as FILLFACTOR, MAXDOP, or a similar numeric setting) falls outside the acceptable boundary defined by SQL Server. This typically happens because of a typo in a T-SQL script, a legacy script written for an older SQL Server version with different limits, or an automated deployment tool passing an incorrect integer value. Since SQL Server 2025 validates these inputs against the sp_configure boundaries or hard-coded engine limits, any value outside this range—including negative numbers or values exceeding the 32-bit/64-bit integer limits—triggers this specific error before the operation can proceed.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Script or Query

  • Open SQL Server Management Studio (SSMS) and review the exact query that triggered the error in the Activity Monitor or Error Log (Application log in Windows Event Viewer under Windows Logs > Application, filtered by Event ID 304).
  • Look specifically for CREATE INDEX, ALTER INDEX, or UPDATE STATISTICS statements that include a numeric parameter (e.g., WITH (FILLFACTOR = 150)).
  • Note the specific option name mentioned in the error message (the %.*ls placeholder will show the actual option, such as MAXDOP or FILLFACTOR).

Step 2: Verify Valid Ranges Using sp_configure

  • Open a new query window in SSMS connected to the affected instance.
  • Run the following command to check current and valid configuration values:
  EXEC sp_configure 'show advanced options', 1;
  RECONFIGURE;
  EXEC sp_configure;
  • Cross-reference the minimum and maximum columns in the result set against the value used in your script (e.g., FILLFACTOR must be between 0 and 100; MAXDOP must align with your CPU core count).

Step 3: Correct the Parameter Value in the Script

  • Edit the T-SQL script to replace the invalid value with one that falls within the range identified in Step 2.
  • If the issue stems from an automated tool (like a migration script or ORM), check the tool’s configuration file (often located in C:\Program Files\Your_Tool\config.xml or a .json settings file) for hard-coded values that need adjusting for SQL Server 2025 compatibility.
  • Re-run the corrected script in SSMS to confirm the object (index or statistics) is created successfully.

Step 4: Apply Instance-Level Configuration Changes (If Applicable)

  • If the error relates to a server-wide setting (like MAXDOP) rather than a single query, update the instance configuration directly:
  EXEC sp_configure 'max degree of parallelism', 8;
  RECONFIGURE WITH OVERRIDE;
  • Restart the SQL Server service via Services.msc on Windows Server 2025 to ensure the change takes effect immediately.

Alternative or Verification Steps

  • To verify the fix, re-execute the original failing query or index maintenance job; if it completes without throwing Error 304, the value is now within the accepted range.
  • As an alternative, use the Database Engine Tuning Advisor or SSMS Object Explorer to right-click the specific index and select “Rebuild,” manually setting the FILLFACTOR via the GUI slider to avoid manual syntax errors in the future.