Delete trigger SQL 2005
I have a rather simple question. I need to create the delete trigger.
I have three table, Main and T1 and T2. The T1 and T2 are connecting to Main with the same ID field so I already开发者_如何学JAVA have insert trigger that works great but I need delete trigger which will delete record in T1 and T2 when deleted from the Main table.
Any help?
A delete trigger would fire after the DELETE runs. However, the DELETE will fail because of foreign key errors (you have FKs, right?).
Options:
- Stored procedure to delete T2, T1 then Main in a transaction
- Set the FKs to have cascading delete
- Instead of trigger (which fires before the delete) which is effectively like a stored procedure
精彩评论