2

I have made a featureclass for a utility company where they can register measures set up to mitigate problems with rats, called "mitigation measure". From this feature class it is possible to state if the current mitigation measure has been removed or not. This field is named "Removed" and it is a domain value with possibilities "Yes", "No" and "Not set".

I now wish to create a sql trigger that can update a time field called "DateRemove" with the current timestamp for the moment the utility company changes the field "Removed" from "No" to "Yes". But only when this exact change happens, not when other changes occur within the feature class.

Evan Carroll
  • 65,432
  • 50
  • 254
  • 507

1 Answers1

1

I changed a few things so that it ended up like this:

Create TRIGGER [sonfor_ags].[trg_date] ON [sonfor_ags].[MitigationMeasure] 
AFTER UPDATE 
AS BEGIN 
SET NOCOUNT ON; 

    UPDATE t SET DateRemove = CURRENT_TIMESTAMP 
    FROM [sonfor_ags].[MitigationMeasure] AS t 
    INNER JOIN inserted AS i ON t.OBJECTID = i.OBJECTID 
       AND i.Removed = 1; END GO 

and now it works perfectly. Thank you very much

LowlyDBA - John M
  • 11,059
  • 11
  • 45
  • 63