Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Delete Trigger Help

Author  Topic 

jrockfl
Posting Yak Master

223 Posts

Posted - 2004-12-17 : 15:06:52
I need help with my first delete trigger. When a row is deleted in tblAutoShip, then id like the details in tblAutoShipDetails to be deleted.

This is what I have so far..
CREATE TRIGGER DeleteAutoShipDetails ON tblautoship
FOR DELETE
AS
DELETE FROM tblautoshipdetails, deleted
WHERE autoshipid =

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-12-17 : 15:20:32
DELETE a
FROM tblautoshipdetails a
INNER JOIN deleted d
WHERE a.PKColumn1 = d.PKColumn1 AND a.PKColumn2 = d.PKColumn2...


Tara
Go to Top of Page

jrockfl
Posting Yak Master

223 Posts

Posted - 2004-12-17 : 15:33:40
Thanks Tara!
Go to Top of Page

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2004-12-17 : 15:42:22
If you have a foreign key constraint between these tables you may want to see if the ON DELETE CASCADE option would save you the overhead of the trigger.

HTH

=================================================================

Happy Holidays!
Go to Top of Page
   

- Advertisement -