Home Forums SQL Server 2008 SQL Server 2008 - General Update a date field with a Trigger when a transaction is posted to another table RE: Update a date field with a Trigger when a transaction is posted to another table

  • In that case use Eirikur's trigger although you could simplify it to

    CREATE TRIGGER trg_LastSaleDate ON dbo.Transheaders

    AFTER INSERT, UPDATE

    AS

    IF UPDATE(TradingDate)

    BEGIN

    UPDATE c

    SET c.ZLastDate = i.TradingDate

    FROM inserted i

    JOIN dbo.Customers c ON c.UniqueID = i.UniqueID

    END

    Far away is close at hand in the images of elsewhere.
    Anon.