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 |
|
nic
Posting Yak Master
209 Posts |
Posted - 2003-04-04 : 13:57:12
|
| Hi I have a table that has about 20 dependant tables. What is the best way to delete all the records associated with the primary record? I have created contraints on all the tables and noticed there a "cascade delete records option". Should I have this checked on all tables, should I create delete triggers, or is there a better way?I know this is a "class 101" type question but I want to follow the preferred path.Nic |
|
|
smccreadie
Aged Yak Warrior
505 Posts |
Posted - 2003-04-04 : 14:00:28
|
| If you set up your tables with foreign relationships and checked the cascade deletes function, then deletions are pretty easy - just delete the primary record. This is the preferred approach.You can also write triggers to do this as well. This was the only was to do it pre-SQL2K. |
 |
|
|
saglamtimur
Yak Posting Veteran
91 Posts |
Posted - 2003-04-04 : 17:38:40
|
| Can you please give a small code example of that kind trigger. I am new on this and no idea. Thanks in advance. |
 |
|
|
samsekar
Constraint Violating Yak Guru
437 Posts |
Posted - 2003-04-07 : 02:05:25
|
| Refer Books OnLine (BOL) on topic "triggers, overview".It has all the details you want.Sekar~~~~Success is not a destination that you ever reach. Success is the quality of your journey. |
 |
|
|
|
|
|