我在下面写了这个触发器。它在以下位置生成错误:
Where UAssignment_Rights.user_id =i.user_id
from Inserted i
我希望当任何行从Users表中删除时。 它还应该从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.'
任何人都可以回答我的这个问题!谢谢。
答案 0 :(得分: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标记此问题)