EDITEDIT: I have explained my problem incorrectly. The question in hand -
Create a trigger on the Appointment table that will update LastContactDate on the Patient table each time a new record is added to the Appointment table. The value of the LastContactDate should be the date the record is added.
How do you create a trigger to update LastContactDate column to record the date every time a new record is added to an Appointment table?
This is what i currently have.
CREATE TRIGGER tr_Appointment_AfterInsert
ON Appointment
AFTER INSERT
AS
BEGIN
INSERT INTO Appointment
SET LastContactDate = GETDATE()
FROM Appointment o
INNER JOIN Inserted i
ON o.AppDate = i.AppDate
AND o.AppStartTime = i.AppStartTime
END
Could you help fix this code?