xcaliber2222
Programmer
Hello, I am trying to update only the most recently inserted record. I thought selecting the MAX id value in the WHERE clause would do the trick, but this keeps updating all the records in the table, instead of the one that was just inserted. Soryy if this seems like a basic question, but if someone could show me where I'm going wrong I would really appreciate it.
Thanks, Alejandro
ALTER TRIGGER primaryVendorFlagUpdate ON [Warranty_Registration]
FOR INSERT
AS
BEGIN
SET NOCOUNT ON
UPDATE Warranty_Registration
SET PRIMARY_VENDOR = a.PRIMARY_VENDOR
FROM dbo.AEO_DEVL_SEQFLEXT a INNER JOIN inserted i ON
a.ENG_SERIAL_NUM = i.Engine_Serial_No AND
a.ENG_MODEL_CD = i.Engine_Model_Code
WHERE Warranty_Registration.Warranty_Reg_ID = (select MAX (Warranty_Registration.Warranty_Reg_ID) from Warranty_Registration)
SET NOCOUNT OFF
END
Thanks, Alejandro
ALTER TRIGGER primaryVendorFlagUpdate ON [Warranty_Registration]
FOR INSERT
AS
BEGIN
SET NOCOUNT ON
UPDATE Warranty_Registration
SET PRIMARY_VENDOR = a.PRIMARY_VENDOR
FROM dbo.AEO_DEVL_SEQFLEXT a INNER JOIN inserted i ON
a.ENG_SERIAL_NUM = i.Engine_Serial_No AND
a.ENG_MODEL_CD = i.Engine_Model_Code
WHERE Warranty_Registration.Warranty_Reg_ID = (select MAX (Warranty_Registration.Warranty_Reg_ID) from Warranty_Registration)
SET NOCOUNT OFF
END