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 |
|
ajit
Starting Member
2 Posts |
Posted - 2004-05-09 : 08:25:03
|
| How do i write a single SQL Query that can delete data from multiple tables at oncefor an exampleLets say i want to delete data from table student and class that contains admissionnumber = 'a123'. Thankx for any help :) |
|
|
LarsG
Constraint Violating Yak Guru
284 Posts |
Posted - 2004-05-09 : 10:18:29
|
| Define a foreign key constraint with on delete cascade. |
 |
|
|
ajit
Starting Member
2 Posts |
Posted - 2004-05-09 : 11:01:16
|
| can u give me an example on how can i implement that..i really new to this..thank you very much :) |
 |
|
|
LarsG
Constraint Violating Yak Guru
284 Posts |
Posted - 2004-05-10 : 03:42:36
|
quote: It involves putting triggers on tables
What?create table student(studentpk datatype primary key, ...)create table class (studentfk datatype references student on delete cascade, classfk datatype references class on delete cascade, primary key(studentfk,classfk), ...) |
 |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2004-05-10 : 08:18:09
|
| I was smoking crack or something. :) I still don't like using cascading deletes though.MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
|
|
|