我正在尝试创建一个在 tablecomponent
和 logging上操作的触发器UPDATE
,DELETE
以及INSERT
对 table 的操作component_history
CREATE TRIGGER component_hist
ON component
AFTER INSERT, UPDATE, DELETE
AS
DECLARE
@tr_action varchar(8),
@tr_id_compoment int,
@tr_name varchar(max),
@tr_value int
IF COLUMNS_UPDATED() <> 0 -- delete or update?
BEGIN
SET @tr_action = 'UPDATE'
ELSE -- delete
BEGIN
SET @tr_action = 'DELETE'
END
INSERT INTO component_history VALUES (@tr_id_component, @tr_name, @tr_value, @tr_action);
如何将id, name, value
表中的列()中的信息发送component
到component_history
?
我试过了:
SET
@tr_id_component = component.id,
@tr_name = component.name,
@tr_value = component.value
但它报告:
消息 4104,级别 16,状态 1,过程 component_hist,第 22 行
无法绑定多部分标识符“component.id”。