SQL Server Error ON DELETE SET NULL

In my database, I have an address table, and this table is used as the primary table in foreign keys with other tables (e.g. clients, employees, etc.)

This SQLFiddle shows the relationship between addressesand customerswhere there customersshould be 2 addresses.

Currently, FK is configured as ON DELETE NO ACTION, and I started changing them to ON DELETE SET NULL.

This works fine for most tables where there is only one address column. In one specific table where there is only one address column and in all tables where there are several address columns, I get an error message:

Msg 1785, Level 16, State 1, Line 1
Representation of the FOREIGN KEY constraint "FK_customers_shipping_address" in the clients table may cause loops or multiple cascading paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION or change other FOREIGN KEY constraints.

Msg 1750, Level 16, State 1, Line 1
Failed to create constraint. See Previous Errors.

If I do not use CASCADE, why am I getting this error? And is there a way around this?

+4
source share
1 answer

SET NULL CASCADE , . " ". .

SQL Server. . .

+1

All Articles