By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,334 Members | 1,266 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,334 IT Pros & Developers. It's quick & easy.

Delete rows from two tables

P: 26
Hi there:

i have a <master> table and a <transaction> table... When a record is deleted from <master> table, i need to make sure that, the associated records in <transaction> table is deleted... Can i do it in a single sql statement or should it be a separate 'delete' statement...

thanks for your help..
cheers
Venu
Jul 23 '07 #1
Share this Question
Share on Google+
5 Replies


10K+
P: 13,264
Hi there:

i have a <master> table and a <transaction> table... When a record is deleted from <master> table, i need to make sure that, the associated records in <transaction> table is deleted... Can i do it in a single sql statement or should it be a separate 'delete' statement...

thanks for your help..
cheers
Venu
Sounds like a job for a trigger on the master table to me.
Jul 23 '07 #2

P: 26
Sounds like a job for a trigger on the master table to me.
i cant use trigger for this due to project constraints... is it possible to have a SQL script to do this...??
Jul 25 '07 #3

10K+
P: 13,264
i cant use trigger for this due to project constraints... is it possible to have a SQL script to do this...??
Yep you can. Just make them seperate statements running one after the other.
Jul 25 '07 #4

P: 12
You could also use referential integrity specifying cascade delete.
Jul 27 '07 #5

10K+
P: 13,264
You could also use referential integrity specifying cascade delete.
I would prefer this method. It's always best to make the DB take care of these things because the DB usually has a longer memory than ours.
Jul 27 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.