当一行插入table_a时,我必须更新table_b中的列。
查询
CREATE TRIGGER trg_Update
ON table_a FOR INSERT
AS
UPDATE table_b
SET Sold_Qty=inserted.qty
WHERE OrdNo=inserted.OrdNo;
我收到以下错误。
Msg 4104, Level 16, State 1, Procedure trg_Update, Line 6
The multi-part identifier "inserted.OrdNo" could not be bound.
答案 0 :(得分:2)
尝试使用此代替UPDATE
查询:
UPDATE table_b
SET Sold_Qty=inserted.qty
FROM table_b b
INNER JOIN inserted ON b.OrdNo=inserted.OrdNo;