Skip to content
Microsoft SQL Server

SQL Server Error 1785

Introducing FOREIGN KEY may cause cycles or multiple cascade paths

Applies to: All supported SQL Server versions (2016 to 2025), Azure SQL Database, Azure SQL Managed Instance
Last technically reviewed 23 October 2026 on SQL Server 2025 (17.0.1145.4)
The full message
Msg 1785, Level 16, State 1, Line 1
Introducing FOREIGN KEY constraint 'FK_OrderItems_Orders' on table 'OrderItems' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
Other forms of this message
Followed by (always, SQL Server 2025)
Msg 1750, Level 16, State 1, Line 1
Could not create constraint or index. See previous errors.
Older wording of the follow-up message (as quoted by Microsoft Learn)
Server: Msg 1750, Level 16, State 1, Line 1 Could not create constraint. See previous errors
Error number
1785
Severity
16 (user-correctable error)
State
1
Product
Microsoft SQL Server Database Engine
Versions
All supported SQL Server versions (2016 to 2025), Azure SQL Database, Azure SQL Managed Instance
Last reviewed
23 October 2026

What it means

Error 1785 means SQL Server refused to create a foreign key because its cascading action (CASCADE, SET NULL or SET DEFAULT) would reach a table by more than one path, or loop back to itself.

This error happens when you create or alter a table, not when you delete data. SQL Server allows each table to appear only once in the tree of cascading actions started by one DELETE or UPDATE. If the new foreign key would add a second route to a table that a cascade already reaches, or a route that leads back to the starting table, the constraint is rejected and the statement fails. The message names the new constraint and the table it was being added to; the existing constraint it clashes with is not named, so look for the other cascading keys on the same tables.

The check is about the declared actions, not your data: it fails even on empty tables. It applies to ON DELETE and ON UPDATE with CASCADE, SET NULL or SET DEFAULT. Error 1785 is always followed by error 1750, which only says the constraint was not created. In a CREATE TABLE the whole table is not created either.

Common causes

  • A "diamond": a child table references both a parent and a middle table, and both routes cascade from the same parent (Customers to Orders to OrderItems, plus Customers to OrderItems).
  • Two foreign keys from one table to the same parent, both with ON DELETE CASCADE (Messages.SenderID and Messages.RecipientID to Users).
  • A self-referencing key (an employee and their manager, a category and its parent) declared with ON DELETE CASCADE or ON DELETE SET NULL.
  • A chain of cascading keys that eventually points back at a table earlier in the chain.

Diagnose it

Read-only These queries only read metadata and dynamic management views. They do not change data, permissions or configuration, so they are safe to run first.

List the cascading foreign keys around the tables involved

SELECT fk.name AS constraint_name,
       OBJECT_NAME(fk.parent_object_id)     AS child_table,
       OBJECT_NAME(fk.referenced_object_id) AS parent_table,
       fk.delete_referential_action_desc, fk.update_referential_action_desc
FROM sys.foreign_keys AS fk
WHERE (fk.delete_referential_action <> 0 OR fk.update_referential_action <> 0)
  AND (OBJECT_NAME(fk.parent_object_id) IN (N'OrderItems', N'Orders')
       OR OBJECT_NAME(fk.referenced_object_id) IN (N'OrderItems', N'Orders', N'Customers'))
ORDER BY parent_table, child_table;
What to look for

Every existing cascading route. The existing key that makes a second path to the table named in the message is the one to change, unless you change the new one.

Show every cascade path from one parent table

A recursive query that follows cascading keys down from a starting table. A table that appears on two rows is reached by two paths.

WITH paths AS (
    SELECT fk.parent_object_id AS table_id,
           CAST(N'Customers > ' + OBJECT_NAME(fk.parent_object_id) AS nvarchar(4000)) AS path,
           1 AS depth
    FROM sys.foreign_keys AS fk
    WHERE fk.referenced_object_id = OBJECT_ID(N'dbo.Customers')
      AND fk.delete_referential_action <> 0
    UNION ALL
    SELECT fk.parent_object_id,
           CAST(p.path + N' > ' + OBJECT_NAME(fk.parent_object_id) AS nvarchar(4000)),
           p.depth + 1
    FROM paths AS p
    JOIN sys.foreign_keys AS fk ON fk.referenced_object_id = p.table_id
    WHERE fk.delete_referential_action <> 0
      AND p.depth < 10
)
SELECT OBJECT_NAME(table_id) AS reached_table, path
FROM paths
ORDER BY reached_table, path;
What to look for

One row per cascading route. Adding a key that would give a table a second row here raises 1785.

How to fix it

Each fix is labelled with what it changes. Try read-only checks and the least invasive fix first, and test changes outside production.

Keep one cascading path and make the other NO ACTION

Changes schema

Choose the route that should cascade (usually the natural parent, Orders for OrderItems) and declare the other key with ON DELETE NO ACTION, which is the default. The second key still protects the data; it just blocks instead of cascading.

CREATE TABLE dbo.OrderItems (
    OrderItemID INT PRIMARY KEY,
    OrderID     INT NOT NULL,
    CustomerID  INT NOT NULL,
    CONSTRAINT FK_OrderItems_Orders
        FOREIGN KEY (OrderID) REFERENCES dbo.Orders (OrderID) ON DELETE CASCADE,
    CONSTRAINT FK_OrderItems_Customers
        FOREIGN KEY (CustomerID) REFERENCES dbo.Customers (CustomerID) ON DELETE NO ACTION
);

Remove the redundant column or key

Changes schema

A diamond often means the child stores something it can already reach. If OrderItems belongs to an order and the order belongs to a customer, OrderItems does not need its own key to Customers; join through Orders instead.

CREATE TABLE dbo.OrderItems (
    OrderItemID INT PRIMARY KEY,
    OrderID     INT NOT NULL
        CONSTRAINT FK_OrderItems_Orders REFERENCES dbo.Orders (OrderID) ON DELETE CASCADE
);

Do the extra deletes in a procedure

Changes data

With the second key set to NO ACTION, delete the rows on that path yourself, children first, in one transaction. Callers use the procedure instead of deleting the parent directly.

Caution: This deletes rows from several tables. Test it on a copy first and make sure every caller goes through the procedure, or the NO ACTION key will block direct deletes with error 547.

CREATE PROCEDURE dbo.DeleteCustomer @CustomerID INT
AS
BEGIN
    SET XACT_ABORT ON;
    BEGIN TRANSACTION;
    DELETE FROM dbo.OrderItems WHERE CustomerID = @CustomerID;
    DELETE FROM dbo.Customers  WHERE CustomerID = @CustomerID;  -- Orders and their items cascade
    COMMIT TRANSACTION;
END;

Self-referencing tables: NO ACTION plus a recursive delete

Changes schema

A hierarchy cannot cascade to itself. Declare the self-reference with NO ACTION and, when a whole subtree must go, collect it with a recursive CTE and delete children before parents (or re-parent them instead).

CREATE TABLE dbo.Employees (
    EmployeeID INT PRIMARY KEY,
    ManagerID  INT NULL
        CONSTRAINT FK_Employees_Manager REFERENCES dbo.Employees (EmployeeID)  -- NO ACTION
);

Examples

Two cascade paths to the same table (a diamond)

CREATE TABLE dbo.Customers (CustomerID INT PRIMARY KEY);
CREATE TABLE dbo.Orders (
    OrderID    INT PRIMARY KEY,
    CustomerID INT CONSTRAINT FK_Orders_Customers REFERENCES dbo.Customers (CustomerID) ON DELETE CASCADE
);

CREATE TABLE dbo.OrderItems (
    OrderItemID INT PRIMARY KEY,
    OrderID     INT,
    CustomerID  INT,
    CONSTRAINT FK_OrderItems_Customers
        FOREIGN KEY (CustomerID) REFERENCES dbo.Customers (CustomerID) ON DELETE CASCADE,
    CONSTRAINT FK_OrderItems_Orders
        FOREIGN KEY (OrderID) REFERENCES dbo.Orders (OrderID) ON DELETE CASCADE
);
Result
Msg 1785, Level 16, State 1, Line 7
Introducing FOREIGN KEY constraint 'FK_OrderItems_Orders' on table 'OrderItems' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
Msg 1750, Level 16, State 1, Line 7
Could not create constraint or index. See previous errors.

Reproduced on SQL Server 2025 (17.0.1145.4), 23 October 2026.

Two foreign keys from one table to the same parent

CREATE TABLE dbo.Users (UserID INT PRIMARY KEY);
CREATE TABLE dbo.Messages (
    MessageID   INT PRIMARY KEY,
    SenderID    INT NOT NULL
        CONSTRAINT FK_Messages_Sender REFERENCES dbo.Users (UserID) ON DELETE CASCADE,
    RecipientID INT NOT NULL
);

ALTER TABLE dbo.Messages ADD CONSTRAINT FK_Messages_Recipient
    FOREIGN KEY (RecipientID) REFERENCES dbo.Users (UserID) ON DELETE CASCADE;
Result
Msg 1785, Level 16, State 1, Line 9
Introducing FOREIGN KEY constraint 'FK_Messages_Recipient' on table 'Messages' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
Msg 1750, Level 16, State 1, Line 9
Could not create constraint or index. See previous errors.

Reproduced on SQL Server 2025 (17.0.1145.4), 23 October 2026.

A self-referencing key with ON DELETE SET NULL

CREATE TABLE dbo.Employees (
    EmployeeID INT PRIMARY KEY,
    ManagerID  INT NULL,
    CONSTRAINT FK_Employees_Manager
        FOREIGN KEY (ManagerID) REFERENCES dbo.Employees (EmployeeID) ON DELETE SET NULL
);
Result
Msg 1785, Level 16, State 1, Line 1
Introducing FOREIGN KEY constraint 'FK_Employees_Manager' on table 'Employees' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
Msg 1750, Level 16, State 1, Line 1
Could not create constraint or index. See previous errors.

Reproduced on SQL Server 2025 (17.0.1145.4), 23 October 2026.

How to prevent it

Sketch the cascade tree before adding ON DELETE CASCADE: from each parent, every table should be reachable by at most one cascading route. Cascade along true ownership (an order owns its lines) and use NO ACTION for references that merely point at something (a message points at a user).

For hierarchies and many-to-one references to the same table, plan the delete logic in a procedure from the start. Run the cascade path query above in code review whenever a migration adds a cascading key. See primary key vs foreign key.

Common questions

Why does SQL Server allow this in other databases but not here?

SQL Server is stricter than some engines: it rejects any design where one DELETE or UPDATE could reach the same table by two cascading routes, even if the result would be the same. You have to keep a single route and handle the rest yourself.

Does ON DELETE SET NULL avoid error 1785?

No. SET NULL and SET DEFAULT are cascading actions too. In our SQL Server 2025 test, a self-referencing key with ON DELETE SET NULL raised 1785 just like CASCADE.

Can I use a trigger instead of a cascade?

Yes. Keep the foreign keys as NO ACTION and put the deletes in an INSTEAD OF DELETE trigger on the parent, deleting children first. A stored procedure is usually easier to read and test.

Learn more on CodeWithSQL

Official documentation

Last technically reviewed 23 October 2026; examples and diagnostics run on SQL Server 2025 (17.0.1145.4). Message text checked against the engine's sys.messages catalogue.

Still stuck on a SQL Server error?

Browse the full SQL Server error library, or get hands-on help from an experienced SQL professional.