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

Troubleshooting Guide: SQL Server Error 1757

Why This Error Happens

Error 1757 occurs when you attempt to create a foreign key constraint between two columns that have mismatched collations. SQL Server requires that both the referencing column (foreign key) and the referenced column (primary/unique key) use the identical collation to ensure consistent string comparison, sorting, and indexing behavior. This mismatch commonly arises when columns are created under different database default collations, or when tables are migrated/restored from servers with different collation settings, particularly during upgrades to SQL Server 2025 on Windows Server 2025 or Windows 11 environments.

Step-by-Step Resolution Guide

Step 1: Identify the Conflicting Collations

  • Open SQL Server Management Studio (SSMS) and connect to the instance reporting the error.
  • Run the following query to check collation settings for both columns involved:
SELECT 
    TABLE_NAME, COLUMN_NAME, COLLATION_NAME 
FROM INFORMATION_SCHEMA.COLUMNS 
WHERE TABLE_NAME IN ('ParentTable', 'ChildTable') 
AND COLUMN_NAME IN ('ParentColumn', 'ChildColumn');
  • Note the discrepancy between the two COLLATION_NAME values returned.

Step 2: Alter the Column Collation to Match

  • Decide which collation should be the “standard” (usually match the database default collation).
  • Use ALTER TABLE to change the collation of the mismatched column. Ensure no indexes are currently relying on this column before altering it.
ALTER TABLE ChildTable
ALTER COLUMN ChildColumn VARCHAR(50) COLLATE SQL_Latin1_General_CP1_CI_AS;
  • Replace SQL_Latin1_General_CP1_CI_AS with the specific collation used by your Parent table’s key column.

Step 3: Drop and Re-create Dependent Indexes (If Applicable)

  • If the column was part of an index or constraint, you may need to drop that dependency first.
  • Navigate to Object Explorer > Databases > YourDB > Tables > YourTable > Indexes in SSMS to manually verify and drop blocking indexes via right-click > Delete.
  • Re-run the ALTER TABLE script from Step 2 once dependencies are cleared.

Step 4: Re-attempt the Foreign Key Creation

  • Once collations match, execute the original ALTER TABLE ADD CONSTRAINT script again.
ALTER TABLE ChildTable
ADD CONSTRAINT FK_Child_Parent FOREIGN KEY (ChildColumn)
REFERENCES ParentTable(ParentColumn);
  • Confirm the command completes without throwing Error 1757.

Alternative or Verification Steps

  • Verification: Right-click the newly created Foreign Key in SSMS under Keys folder and select “Script Key as” > “CREATE To” to confirm it exists in the schema without errors.
  • Alternative: If altering the column collation is not feasible due to application dependencies, use the COLLATE clause directly within the JOIN or WHERE logic of specific queries to bypass comparison errors, though this does not resolve the underlying constraint creation issue.