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

Troubleshooting Guide: SQL Server Error 1786 – Timestamp Column in Cascading Foreign Key

Why This Error Happens

This error occurs because SQL Server does not permit the timestamp (or rowversion) data type to participate in a foreign key relationship that uses ON UPDATE CASCADE or ON DELETE CASCADE actions. Since the timestamp/rowversion value is automatically generated and modified by the database engine on every row update, allowing cascading operations on it would create a logical conflict between automatic versioning and relational integrity propagation. This is a schema design restriction enforced at the engine level, not a permissions or connectivity issue.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Column and Constraint

  • Run the following query to locate the foreign key and the specific column causing the issue:
  SELECT fk.name AS ForeignKeyName, c.name AS ColumnName, t.name AS DataType
  FROM sys.foreign_key_columns fkc
  JOIN sys.foreign_keys fk ON fkc.constraint_object_id = fk.object_id
  JOIN sys.columns c ON fkc.parent_object_id = c.object_id AND fkc.parent_column_id = c.column_id
  JOIN sys.types t ON c.user_type_id = t.user_type_id
  WHERE t.name = 'timestamp';
  • Confirm whether the column in question is the referencing column or the referenced column, as reported in the error message.

Step 2: Remove Cascading Behavior from the Foreign Key

  • Script out the existing foreign key constraint using SQL Server Management Studio (SSMS) or Azure Data Studio before making changes.
  • Drop the constraint and recreate it without ON UPDATE CASCADE or ON DELETE CASCADE:
  ALTER TABLE dbo.YourChildTable
  DROP CONSTRAINT FK_YourForeignKeyName;

  ALTER TABLE dbo.YourChildTable
  ADD CONSTRAINT FK_YourForeignKeyName
  FOREIGN KEY (YourColumn) REFERENCES dbo.YourParentTable(ParentColumn)
  ON DELETE NO ACTION
  ON UPDATE NO ACTION;

Step 3: Redesign the Schema if Cascading Is Required

  • If cascading behavior is a business requirement, change the underlying column’s data type from timestamp/rowversion to a standard type (e.g., int, bigint, or datetime2) that supports cascading referential integrity.
  • Update any application code, triggers, or stored procedures that reference the old timestamp column, since removing it may affect optimistic concurrency checks.

Step 4: Apply Changes via a Maintenance Window

  • Test the altered schema in a non-production environment first, especially on Windows Server 2025 instances using Always On Availability Groups, since schema changes to replicated tables require synchronization.
  • Deploy the validated script during a scheduled maintenance window using SQL Server Agent or a deployment pipeline (e.g., Azure DevOps or SSDT).

Alternative or Verification Steps

  • After applying the fix, re-run the CREATE or ALTER TABLE statement that originally failed; Error 1786 should no longer appear, and the constraint will show CASCADE options as NONE when queried via sys.foreign_keys.
  • If schema redesign is not immediately feasible, implement the cascading logic manually using an INSTEAD OF trigger on the parent table to propagate updates/deletes to child tables, bypassing the native cascade restriction.