Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DELETE From Multiple tables

Status
Not open for further replies.

nirs

IS-IT--Management
Apr 4, 2003
37
IL
is there a way to DELETE from Multiple table that are linked

e.g.
DELETE
FROM dbo.T_Measurment RIGHT OUTER JOIN
dbo.T_Item ON dbo.T_Measurment.itemNo = dbo.T_Item.itemNo RIGHT OUTER JOIN
dbo.T_Batch ON dbo.T_Item.batchNo = dbo.T_Batch.batchNo LEFT OUTER JOIN
dbo.T_BatchRemark ON dbo.T_Batch.batchNo = dbo.T_BatchRemark.batchNo

i want to do that insted of checking each table befor deleting. this has to be done because of constraints.

thank you
 
because of constraints? what kind of constraints?

if they are foreign key constraints....

also, which tables to you want to delete from? your example query links several tables, do you want to delete everything from all of them? or just linked rows from all of them? or only unmatched rows? (i'm guessing, because you used RIGHT OUTER)

a little more detail, if you please

rudy
SQL Consulting
 
i want to delete records under a where condition
i all those tables are conected and insted of deleting from each table separatly i want to do it in one time
 
perhaps you could do it with a cascading delete

define primary and foreign keys on your tables, and on the foreign keys, declare ON DELETE CASCADE

then the database will delete all related rows for you automatically

:)

rudy
SQL Consulting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top