467,185 Members | 1,238 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,185 developers. It's quick & easy.

Delete rows from two tables

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
  • viewed: 2407
Share:
5 Replies
8TB
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
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
8TB
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
You could also use referential integrity specifying cascade delete.
Jul 27 '07 #5
8TB
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.

Similar topics

2 posts views Thread by michael | last post: by
16 posts views Thread by robert | last post: by
3 posts views Thread by razheev | last post: by
2 posts views Thread by NoSpam | last post: by
2 posts views Thread by Jim McGivney | last post: by
5 posts views Thread by tony010409020622@hotmail.com | last post: by
5 posts views Thread by rn5a@rediffmail.com | last post: by
5 posts views Thread by Tony Johansson | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.