Home > database >  How to only change the current new data in the trigger?
How to only change the current new data in the trigger?

Time:11-10

T_IM_MaterialReqBill originally there are some records in the table, below the trigger is executed, some of the original records are updated together, how to implement the original record is not updated, only update the newly inserted row?

CREATE the TRIGGER [dbo] [T_IM_MaterialReqBill - DDS] ON [dbo] [T_IM_MaterialReqBill]
FOR INSERT, UPDATE
AS
The BEGIN
The UPDATE t1 SET t1. CFSCDDS=t2. FQTY
The FROM T_IM_MaterialReqBill t1
INNER JOIN T_MM_ManufactureOrder t2 ON t2. FID=t1. FSourceBILLID
WHERE t1. FSourceBillTypeID='B2aZSVXaSx6qxdfekgCmrEY + 1 vi='
END

CodePudding user response:

You have to associated Inserted

 
CREATE the TRIGGER [dbo] [T_IM_MaterialReqBill - DDS] ON [dbo] [T_IM_MaterialReqBill]
FOR INSERT, UPDATE
AS
The BEGIN
The UPDATE t1 SET t1. CFSCDDS=t2. FQTY
The FROM INSERTED t1
INNER JOIN T_MM_ManufactureOrder t2 ON t2. FID=t1. FSourceBILLID
END
  • Related