-2

我在下面写了这个触发器。它在以下位置产生错误:

Where UAssignment_Rights.user_id =i.user_id

from Inserted i

我希望当从用户表中删除任何行时。它还应该从 中删除Deleted User详细信息UAssignment_Rights Table 在此处输入图像描述

在上图中Normalized Table is named as UAssignment_Rights

CREATE TRIGGER Trigger_Update ON Users
FOR DELETE
AS
    set nocount on
DELETE 
FROM   UAssignment_Rights

        Where UAssignment_Rights.user_id =i.user_id
        from Inserted i

       PRINT 'AFTER INSERT trigger fired.'

谁能回答我这个问题!谢谢你。

4

1 回答 1

1

使用 .删除时,您的语法是错误的JOIN。试试这个:

CREATE TRIGGER Trigger_Update ON Users
FOR DELETE
AS
SET NOCOUNT ON;

DELETE UR
FROM   UAssignment_Rights UR
INNER JOIN Deleted D
ON UR.[user_id] = D.[user_id]

PRINT 'AFTER INSERT trigger fired.'

此外,这适用于 SQL Server(这似乎是您正在使用的实际 RDBMS,我不知道您为什么也用 MySQL 标记了这个问题)

于 2013-08-29T21:43:56.947 回答