I created a table with the following columns: ObservationId, FirstCreatedDate, Description, ...... and LastUpdatedDate in SQL Server 2008 R2. ObservationId is an identifier in increments of 1.
I need to create two triggers, one for INSERT and one for UPDATE. When adding a new record, the INSERT trigger will update the FirstCreatedDate column, receiving the current time; when updating an existing record, the UPDATE trigger updates LastUpdatedDate colunm to get the current datetime.
I was not able to do this because I assume that the identification problem may be a problem.
Can anyone give me a hand? Thanks!
Cheers, Alex
ALTER TRIGGER [dbo].[T_InsertNewObservation] ON [dbo].[GCUR_OBSERVATION] AFTER INSERT AS BEGIN
source share