Troubleshooting Guide: SQL Server Error 315 — Disabled Index or Offline Filegroup
Why This Error Happens
This error occurs when a query references a table whose index has been explicitly disabled (via ALTER INDEX ... DISABLE) or when the index resides in a filegroup that is currently offline, restoring, or otherwise inaccessible. SQL Server 2025 cannot use the query optimizer’s chosen access path if the underlying index structure is unavailable, and unlike a missing table, it will not silently fall back to a table scan when an index is explicitly disabled. This is commonly triggered after a partial database restore, a filegroup failure, corrupted data files, or a maintenance script that disabled indexes for a bulk load and never re-enabled them.
Step-by-Step Resolution Guide
Step 1: Identify the Disabled Index or Offline Filegroup
- Run the following query to check index status:
SELECT i.name AS IndexName, i.is_disabled, t.name AS TableName FROM sys.indexes i JOIN sys.tables t ON i.object_id = t.object_id WHERE i.is_disabled = 1;- Cross-reference the filegroup status using
SELECT name, state_desc FROM sys.filegroups;orSELECT name, state_desc FROM sys.database_files; - Note whether the issue is a disabled index (logical) or an offline filegroup (physical/storage).
Step 2: Rebuild the Disabled Index (If Applicable)
- If the index was disabled intentionally (e.g., before a bulk insert), rebuild it using:
ALTER INDEX [IndexName] ON [SchemaName].[TableName] REBUILD;- For all disabled indexes on a table at once, use
ALTER INDEX ALL ON [TableName] REBUILD; - Confirm sufficient disk space exists on the drive hosting the data files, typically under
C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\on Windows Server 2025/Windows 11 default installs.
Step 3: Bring the Filegroup Back Online
- Check the physical file path status in SQL Server Configuration Manager or via
sys.master_files. - If the filegroup is marked
OFFLINEdue to a missing or corrupted.ndf/.mdffile, verify the file exists at its expected path (e.g.,D:\SQLData\SecondaryFG.ndf). - Restore the affected filegroup from the most recent backup using:
RESTORE DATABASE [YourDB] FILEGROUP = 'YourFileGroup' FROM DISK = 'D:\Backups\YourDB.bak' WITH RECOVERY;- If the underlying disk or storage volume was disconnected (common in Windows Server 2025 storage spaces configurations), reattach the volume via Disk Management first.
Step 4: Review SQL Server Error Logs and Event Viewer
- Open Event Viewer on Windows Server 2025/Windows 11 and navigate to
Applications and Services Logs > MSSQLSERVER. - Cross-reference Error 315 timestamps with any I/O or storage-related warnings (Error 823/824) that may indicate the root storage issue.
- Check
ERRORLOGlocated atC:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOGfor additional context on why the filegroup went offline.
Alternative or Verification Steps
- Re-run the original query that triggered Error 315 and confirm it executes without the disabled index/filegroup message; also validate with
DBCC CHECKDB('YourDB') WITH NO_INFOMSGSto confirm database integrity. - If rebuilding fails due to storage corruption, restore the entire database from the last known good full backup rather than attempting a filegroup-only recovery.