0
I’ve got Trigger down:
CREATE TRIGGER AtualizaDataAlteracaoSegmentos
ON dbo.Segmentos
AFTER INSERT,UPDATE
AS
BEGIN
Begin tran
update Segmentos
set DataAlteracao = GETDATE()
where Id = (select ID from inserted);
Commit;
END;
Is there any way I can update this field without activating Trigger again?
In Oracle know what could do in BEFORE and instead of giving the update so assign the value of NEW.dataAlteracao however in SQL Server do not know how to proceed.
In the case of INSERT, simply declare the Date change column with the default value of CURRENT_TIMESTAMP. This already eliminates the need for the trigger procedure to treat AFTER INSERT.
– José Diz