1st thing, I think both of your triggers will need unique names. Then
assuming you are only ever deleting one item at time you can try
these...


CREATE TRIGGER trig_PosDelete ON position FOR DELETE
AS
DECLARE @deletedID int
SELECT @deletedID = position_id from deleted
BEGIN TRAN
DELETE FROM question
WHERE position_id = @deletedID
COMMIT TRAN

CREATE TRIGGER trig_QuesDelete ON question FOR DELETE
AS
DECLARE @deletedID int
SELECT @deletedID = question_id from deleted
BEGIN TRAN
DELETE FROM resume_applications
WHERE question_id = @deletedID
COMMIT TRAN


That's off the top of my head, but should work ok.

Craig.


-----Original Message-----
From: Duane Boudreau [mailto:[EMAIL PROTECTED]] 
Sent: 03 December 2002 17:15
To: CF-Talk
Subject: SQL:Trigger Question

Hi All,

I have a db (MSSQL) with the following tables:

Position         Questions     Response
position_id  question_id   response_id
             position_id   question_id

I need to design the triggers that will automatically delete related
records
from the question and responses table.

I thought my triggers should look like:

CREATE TRIGGER trig_Delete ON position
FOR DELETE
AS
DELETE
FROM question
WHERE position_id = deleted.position_id

CREATE TRIGGER trig_Delete ON question
FOR DELETE
AS
DELETE
FROM resume_applications
WHERE question_id = deleted.question_id


Can anyone help me out on the correct syntax here?

Thanks,
Duane


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm

Reply via email to