I have two tables users
and bans
.
The second table has two columns user_id_from
and user_id_to
with foreign keys to column id
of the first table. I set ON UPDATE option to both and it throw me an error. I work in VS with SQL Server and only get a message "Script execution error" without description.
The script is executing if I add an option for only one key but I can't understand why it's not working for both together like in the code below.
CREATE TABLE [users]
(
[id] INT IDENTITY (1, 1) NOT NULL,
PRIMARY KEY CLUSTERED ([id] ASC)
);
CREATE TABLE [bans]
(
[id] INT IDENTITY (1, 1) NOT NULL,
[user_id_from] INT NOT NULL,
[user_id_to] INT NOT NULL,
PRIMARY KEY CLUSTERED ([id] ASC),
CONSTRAINT [FK_1_bans_TO_users]
FOREIGN KEY ([user_id_from]) REFERENCES [dbo].[users] ([id])
ON UPDATE CASCADE,
CONSTRAINT [FK_2_bans_TO_users]
FOREIGN KEY ([user_id_to]) REFERENCES [dbo].[users] ([id])
ON UPDATE CASCADE
);