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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-06-11 : 21:39:49
|
Jagan Kumar writes "Hi,
I hav egone through the question about cascade delete using trigger and also the answer for that. But I tried a trigger using the script similar to this but it is giving the referential integrity error.
According to my knowledge SQL Server triggers are "after" triggers, not "before". So for cascade delete using the below script is not working for me. Since whenever I use the delete statement for the master table it raises the error so no point of execution for the delete trigger.
Could you please clarify my doubts.
the sample code as in the www.4guysfromrolla.com site.
CREATE TRIGGER stock_cascade_delete ON Stock FOR DELETE AS
DELETE FROM Stock_Transactions WHERE Stock_Code IN ( SELECT Stock_Code FROM deleted )
What I understood is that Stock is the master table and Stock_Transactions is the transaction table" |
|
|
|
|
|