0

我想在插入值后更新一些数据列。但这给了我一些错误。请帮我解决这个问题。

消息 4104,级别 16,状态 1,过程 TriggerBonus,第 20 行
无法绑定多部分标识符“i.User_id”。

触发:

CREATE TRIGGER [dbo].[TriggerBonus] ON [dbo].[Bonus]
FOR INSERT
AS
DECLARE @rcnt int 
SELECT @rcnt = @@rowcount

IF(SELECT COUNT(*) FROM Bonus,inserted WHERE Bonus.Tpv = inserted.Tpv)!=@@rowcount

/* Cancel the insert and print a message.*/
      begin
      rollback transaction 
      end  

/* Otherwise, allow it. */
else

UPDATE Bonus
SET Subdealers_Id=('user')
WHERE (User_id = i.User_id)
4

1 回答 1

1

您的更新需要:

UPDATE Bonus
SET Subdealers_Id=('user')
from inserted i inner join Bonus 
on {put your join here}
WHERE (User_id = i.User_id)
于 2012-06-01T07:54:49.470 回答