I want to set up a trigger so when I delete a record in table1, the same(related) reocrd in table2 can be deleted automatically.
Here is the query I put in --
CREATE TRIGGER Delete_Leave_Trigger ON Calendar
FOR DELETE AS
DECLARE @CalendarID INTEGER
DELETE FROM LeaveDate Where CalendarID = CalendarID
The result is when I delete a record in table1, "all" records in table2 are deleted. If I change "@CalendarID" in the query to "@CalendarID_d", it says the syntax is not correct.
Help please.
Here is the query I put in --
CREATE TRIGGER Delete_Leave_Trigger ON Calendar
FOR DELETE AS
DECLARE @CalendarID INTEGER
DELETE FROM LeaveDate Where CalendarID = CalendarID
The result is when I delete a record in table1, "all" records in table2 are deleted. If I change "@CalendarID" in the query to "@CalendarID_d", it says the syntax is not correct.
Help please.