IF EXISTS (SELECT 1 FROM sys.triggers WHERE object_id = OBJECT_ID('ActivityUpdateTrigger'))
    DROP TRIGGER ActivityUpdateTrigger
GO

CREATE TRIGGER ActivityUpdateTrigger ON Activity
INSTEAD OF UPDATE
AS
BEGIN
    UPDATE DT463 
    SET 
        DI000269 = inserted.DI000269, 
        /*DI008850 = CASE WHEN UPDATE("parentActivityUUID") THEN (SELECT pact.DI001097 FROM DT463 pact WHERE pact.UUID = inserted."parentActivityUUID") ELSE DI008850 END, 
		DI008851 = CASE WHEN UPDATE("parentActivityUUID") THEN (SELECT pact.DI001098 FROM DT463 pact WHERE pact.UUID = inserted."parentActivityUUID") ELSE inserted.DI008851 END, */
        DI001110 = inserted.DI001110, DI001111 = inserted.DI001111, DI001112 = inserted.DI001112, 
        DI001113 = inserted.DI001113, DI001114 = inserted.DI001114, DI001115 = inserted.DI001115, 
        DI001116 = inserted.DI001116, DI001117 = inserted.DI001117, DI001118 = inserted.DI001118, 
        DI001119 = inserted.DI001119, DI001120 = inserted.DI001120, DI001121 = inserted.DI001121, 
        DI001122 = inserted.DI001122, DI001129 = inserted.DI001129, DI001130 = inserted.DI001130, 
        DI001131 = inserted.DI001131, DI001132 = inserted.DI001132, DI001133 = inserted.DI001133, 
        DI001134 = inserted.DI001134, DI001135 = inserted.DI001135, DI001136 = inserted.DI001136,
        DI002482 = inserted.DI002482, DI001123 = inserted.DI001123, DI001124 = inserted.DI001124, 
        DI001140 = inserted.DI001140, DI001141 = inserted.DI001141, DI001142 = inserted.DI001142, 
        DI001143 = inserted.DI001143, DI001144 = inserted.DI001144, DI001145 = inserted.DI001145, 
        DI001146 = inserted.DI001146, DI001147 = inserted.DI001147, DI001148 = inserted.DI001148, 
        DI001149 = inserted.DI001149, DI001150 = inserted.DI001150, DI001488 = inserted.DI001488, 
        DI003019 = inserted.DI003019, DI003020 = inserted.DI003020, DI009480 = inserted.DI009480, 
        DI001163 = inserted.DI001163, DI006786 = inserted.DI006786, DI008845 = inserted.DI008845, 
        DI008846 = inserted.DI008846, DI008847 = inserted.DI008847, DI009343 = inserted.DI009343, 
        DI009344 = inserted.DI009344, DI009345 = inserted.DI009345, DI009346 = inserted.DI009346, 
        /* COSTS */ 
        DI001633 = inserted.DI001633, DI001634 = inserted.DI001634, DI001635 = inserted.DI001635, 
        DI001636 = inserted.DI001636, DI000696 = inserted.DI000696, DI000697 = inserted.DI000697, 
        DI000698 = inserted.DI000698, DI000715 = inserted.DI000715, DI028406 = inserted.DI028406, 
        DI028407 = inserted.DI028407, DI028408 = inserted.DI028408, DI028409 = inserted.DI028409, 
        DI028410 = inserted.DI028410, DI028411 = inserted.DI028411, DI028412 = inserted.DI028412, 
        DI028413 = inserted.DI028413, CRITICAL_PATH = inserted.CRITICAL_PATH, LONGEST_CRITICAL_PATH = inserted.LONGEST_CRITICAL_PATH
    FROM inserted
    WHERE 
        DT463.UUID = inserted.UUID;
END;
GO
