Troubleshooting Guide: SQL Server Error 1994
Error Message: Cannot create or update statistics on view "%.*ls" because both FULLSCAN and NORECOMPUTE options are required.
Why This Error Happens
This error occurs because indexed views in SQL Server impose a stricter requirement on statistics management than standard tables. When creating or updating statistics manually on a view, SQL Server mandates that both the FULLSCAN and NORECOMPUTE options be explicitly specified together, since sampled or auto-updating statistics on view data can produce inconsistent query optimizer estimates. The error is triggered when a CREATE STATISTICS or UPDATE STATISTICS command omits one or both of these required clauses, or when a maintenance script/third-party tool generates statistics commands without view-specific logic.
Step-by-Step Resolution Guide
Step 1: Identify the Offending Statement
- Check the SQL Server error log or the application/job that triggered the statistics update.
- Locate the exact
CREATE STATISTICSorUPDATE STATISTICScommand targeting the view. - Example of an invalid command that triggers this error:
UPDATE STATISTICS dbo.MyIndexedView
Step 2: Rewrite the Statement with Required Options
- Modify the command to explicitly include both
WITH FULLSCANandNORECOMPUTE. - Correct syntax example:
UPDATE STATISTICS dbo.MyIndexedView
WITH FULLSCAN, NORECOMPUTE;
- If creating new statistics on the view, use:
CREATE STATISTICS stat_MyView
ON dbo.MyIndexedView (ColumnName)
WITH FULLSCAN, NORECOMPUTE;
Step 3: Audit Maintenance Plans and Scripts
- Open SQL Server Management Studio (SSMS) and navigate to SQL Server Agent > Jobs.
- Review any Maintenance Plan “Update Statistics Task” or Ola Hallengren–style
IndexOptimizescripts. - If using Ola Hallengren’s scripts, ensure the
@UpdateStatisticsparameter logic correctly excludes views from auto-sampled statistics, or add a custom override for indexed views usingFullScan='Y'.
Step 4: Apply Fix to All Affected Views
- Query
sys.viewsjoined withsys.indexesto find all indexed views in the database:
SELECT v.name AS ViewName, i.name AS IndexName
FROM sys.views v
JOIN sys.indexes i ON v.object_id = i.object_id
WHERE i.index_id = 1;
- Apply the corrected
WITH FULLSCAN, NORECOMPUTEsyntax to each view identified in the result set.
Step 5: Restart Dependent Services (If Applicable)
- If the error originated from a scheduled job or linked automation tool (e.g., SSIS package, PowerShell script), restart the SQL Server Agent service on Windows Server 2025 to clear any cached job step definitions.
- Path:
Services.msc > SQL Server Agent (MSSQLSERVER) > Restart.
Alternative or Verification Steps
- Verify the fix by re-running the corrected
UPDATE STATISTICScommand and confirming no error is returned; then checksys.statsandsys.dm_db_stats_propertiesto confirm theis_temporaryflag and last update timestamp reflect the recent full scan. - As an alternative, if manual statistics management is not critical, drop the custom statistics object on the view entirely and allow SQL Server to manage it automatically via indexed view rebuild (
ALTER INDEX ... REBUILD), which implicitly satisfies the FULLSCAN/NORECOMPUTE requirement.