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 |
|
ujjaval
Posting Yak Master
108 Posts |
Posted - 2005-12-19 : 00:06:20
|
| Hi,I have got the code for trigger which does cascade delete. The code is as shown below:CREATE TRIGGER dbo.TRG_cascade_delete ON PrimaryTable FOR DELETE AS DELETE FROM SecTbl FROM SecondaryTable SecTbl INNER JOIN deleted d ON SecTbl.col1 = d.col1>> I have PrimaryTable and SecondaryTable in my database. But I don't have 'SecTbl' and 'deleted d' in my database. Can somebody explain me how this works?? |
|
|
shallu1_gupta
Constraint Violating Yak Guru
394 Posts |
Posted - 2005-12-19 : 00:37:50
|
| sectbl is an alias name for secondarytable whereas there are 2 magic tables deleted and inserted. whenever an update statement is fired the row which needs to be updated is copied into deleted table and the updated row is inserted into an inserted table. These tables are mantained internally by sql server and can be accessed only in triggers. you can refer BOL for more information on these magic tables.for more information refer http://msdn.microsoft.com/library/default.asp?url=/library/en-us/createdb/cm_8_des_08_0lo3.asp |
 |
|
|
|
|
|