473,472 Members | 2,143 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Delete rows from two tables

26 New Member
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
5 2656
r035198x
13,262 MVP
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
bharadwajrv
26 New Member
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
r035198x
13,262 MVP
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
FritzLeblanc
12 New Member
You could also use referential integrity specifying cascade delete.
Jul 27 '07 #5
r035198x
13,262 MVP
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

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

Similar topics

2
by: michael | last post by:
Gotta post because this is driving me nuts. Trying to DELETE orphans. I can successfully: SELECT GroupID FROM Groups LEFT JOIN Users ON UsersID = UserID WHERE UsersID IS NULL; but when I...
2
by: Bob Ganger | last post by:
Hello, I am working on a project using SQL Server 2000 with a database containing about 10 related tables with a lot of columns containing text. The total current size of the database is about...
16
by: robert | last post by:
been ruminating on the question (mostly in a 390/v7 context) of whether, and if so when, a row update becomes an insert/delete. i assume that there is a threshold on the number of columns of the...
3
by: razheev | last post by:
Hi, I am doing a purge process and trying to delete rows .Let me know how efficiently I can handle the purge process because of the RI on the tables. TABLE A is a PARENT of TABLE B, TABLE C,...
2
by: NoSpam | last post by:
Hi, I am working with C# and ASP.NET with code behind and a SQL Server. I'm making an e-shop. When clients see what they have in their basket, I added a function DELETE to delete a line. It took...
2
by: Jim McGivney | last post by:
I am using a Microsoft Book as a guide and trying to construct a Delete Command Event Handler for a DataGrid. The book lists the statement: ...
5
by: tony010409020622 | last post by:
I just spent 4 months taking a dotnet class where i learned very little. One of the things I did not learn is this: What are the dotnet equivilents of commands such as: Adodc1.Recordset.AddNew...
6
by: polocar | last post by:
Hi, I'm writing a program in Visual C# 2005 Professional Edition. This program connects to a SQL Server 2005 database called "Generations" (in which there is only one table, called...
5
by: rn5a | last post by:
The .NET 2.0 documentation states the following: When using a DataSet or DataTable in conjunction with a DataAdapter & a relational data source, use the Delete method of the DataRow to remove...
5
by: Tony Johansson | last post by:
Hello! Here I have a working program that delete the specified row in the database. It works fine but I want to fully understand it. In this example the SQLCommandBuilder will automatically...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.