我正在尝试调用ON Delete
触发事件,但是当我尝试从Deleted
表中选择行时,它是空的。
有没有其他方法可以获取触发删除事件的行 ID?
代码:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER TRIGGER [audit]
ON [dbo].[S_PARTY]
FOR DELETE
AS
-- Insert statements for trigger here
DECLARE @id nvarchar(50)
SET @id = (Select ROW_ID from deleted )
BEGIN
-- Insert statements for trigger here
INSERT INTO [dbo].[S_AMF_AUDIT_ITEM] (ROW_ID)
VALUES (@id);
END
当触发器对此触发时,我收到错误,因为S_AMF_AUDIT_ITEM
不允许空值。那么您能帮我获取执行删除命令的表的 ID 吗?