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

Why This Error Happens

Error 13130 occurs when SQL Server 2025 attempts to create or rebuild a nonclustered index on a memory-optimized table, but the index definition violates In-Memory OLTP engine constraints—most commonly a missing BUCKET_COUNT value for a hash index, or a column data type/size exceeding the 8,060-byte row limit for a durable memory-optimized table. This is frequently triggered after migrating a traditional disk-based table to MEMORY_OPTIMIZED = ON without adjusting the index syntax. It can also surface if the underlying filegroup for memory-optimized data is corrupted or not properly mapped, causing the Storage Engine to reject the index metadata during validation.

Step-by-Step Resolution Guide

Step 1: Validate the Index Definition Syntax

  • Open SQL Server Management Studio (SSMS) and locate the CREATE TABLE or ALTER TABLE statement that failed.
  • Confirm that any NONCLUSTERED HASH index explicitly includes a BUCKET_COUNT clause, e.g.:
  INDEX ix_test NONCLUSTERED HASH (OrderID) WITH (BUCKET_COUNT = 1000000)
  • If the index does not require hashing, switch to a standard NONCLUSTERED (range) index instead.

Step 2: Check Column Data Types and Row Size Limits

  • Run the following query to inspect column types on the affected table:
  EXEC sp_help 'dbo.YourTableName';
  • Ensure no (n)varchar(max), text, or image types are used in memory-optimized index keys—these are unsupported.
  • Reduce column widths or move oversized columns to a separate disk-based table if necessary.

Step 3: Repair or Recreate the Memory-Optimized Filegroup

  • Navigate to Object Explorer > Databases > YourDB > Storage > Filegroups in SSMS and confirm the MEMORY_OPTIMIZED_DATA filegroup path is valid (e.g., C:\SQLData\MemoryOptimized\).
  • If the path is broken or inaccessible, detach and reattach the database, or restore from a known-good backup.
  • Run DBCC CHECKDB (YourDB) WITH NO_INFOMSGS, ALL_ERRORMSGS; to confirm no corruption remains.

Step 4: Rebuild the Index with Corrected Parameters

  • Drop the faulty index:
  DROP INDEX ix_test ON dbo.YourTableName;
  • Recreate it using the corrected BUCKET_COUNT or data type adjustments from Steps 1–2.
  • Restart the SQL Server service via services.msc on Windows Server 2025/Windows 11 if the schema change does not take effect immediately.

Alternative or Verification Steps

  • Verify the fix by querying sys.indexes and sys.hash_indexes to confirm the new index shows a valid bucket_count value and no error is logged in the SQL Server Error Log (Management > SQL Server Logs in SSMS).
  • If the issue persists, consider converting the memory-optimized table back to a disk-based table temporarily, apply the schema changes, then re-enable MEMORY_OPTIMIZED = ON to force metadata regeneration.