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

Troubleshooting Guide: Error 1775 – Foreign Key Creation Fails Due to Disabled Primary Key Index

Why This Error Happens

This error occurs because the primary key index on the referenced table has been explicitly disabled, typically as a result of a maintenance operation (such as an ALTER INDEX ... DISABLE command) that was never reverted. SQL Server requires the primary key index to be active and rebuilt in order to validate referential integrity when creating a new foreign key constraint. Since a disabled index retains its metadata but not its usable data structure, the Database Engine blocks the foreign key creation to prevent linking to an unverifiable key.

Step-by-Step Resolution Guide

Step 1: Identify the Disabled Index

  • Open SQL Server Management Studio (SSMS) and connect to the target instance.
  • Run the following query to locate disabled indexes on the referenced table:
SELECT name, is_disabled 
FROM sys.indexes 
WHERE object_id = OBJECT_ID('YourSchema.YourTableName') AND is_disabled = 1;
  • Confirm that the Primary Key index listed in the Error 1775 message matches the output.

Step 2: Rebuild the Disabled Primary Key Index

  • Execute an ALTER INDEX command to rebuild and re-enable the specific index.
  • Use the following T-SQL syntax, replacing the index and table names accordingly:
ALTER INDEX [PK_YourIndexName] ON [YourSchema].[YourTableName] REBUILD;
  • Ensure you have sufficient disk space in the relevant filegroup, as a rebuild operation requires temporary space to recreate the B-tree structure.

Step 3: Verify Table and Constraint Integrity

  • Run DBCC CHECKTABLE('YourTableName') to ensure no underlying corruption caused the index to be disabled in the first place.
  • Check the SQL Server Error Log (via SSMS Management > SQL Server Logs) for any prior I/O or corruption-related events tied to this table.

Step 4: Re-attempt the Foreign Key Creation

  • Once the index status changes from is_disabled = 1 to is_disabled = 0, re-run your original ALTER TABLE ... ADD CONSTRAINT script.
  • Example:
ALTER TABLE [ChildTable] 
ADD CONSTRAINT FK_Child_Parent FOREIGN KEY (ParentID) 
REFERENCES [ParentTable](ID);

Alternative or Verification Steps

  • Verification: Query sys.indexes again to confirm is_disabled = 0 for the Primary Key, and check sys.foreign_keys to verify the new constraint exists with is_disabled = 0.
  • Alternative: If rebuilding fails due to resource constraints, drop and recreate the Primary Key constraint entirely using ALTER TABLE ... DROP CONSTRAINT followed by ADD CONSTRAINT ... PRIMARY KEY, ensuring you schedule this during a maintenance window to avoid blocking active transactions.