Delete Query on Joined Tables on SQL Server 
Author Message
 Delete Query on Joined Tables on SQL Server

I have been trying to delete in one SQL statement, several records from
several tables. I am deleting one record in table A with a foreign key
to many records in table B, and these have also foreign keys and a
one-to-many relationship with table C.  How do I delete all the child
records from these tables without using 3 SQL delete queries, or setting
up Delete triggers on SQL server>



Wed, 18 Aug 1999 03:00:00 GMT  
 Delete Query on Joined Tables on SQL Server

Quote:

> I have been trying to delete in one SQL statement, several records from
> several tables. I am deleting one record in table A with a foreign key
> to many records in table B, and these have also foreign keys and a
> one-to-many relationship with table C.  How do I delete all the child
> records from these tables without using 3 SQL delete queries, or setting
> up Delete triggers on SQL server>

OK in one big sql statement you will nest 3 transactions, the first will
delete the lowest level child records the next will delete the middle
level child and the last will delete the paren records, if an error
occurrs anywhere just rollback and all will be ok

try a stored procedure

good luck



Wed, 18 Aug 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. SQL Join Query over 3 tables

2. SQL Server: GetChunk and Joined Tables

3. SQL delete query deletes but does not delete

4. How do you delete SQL server tables

5. SQL - Join one table in one destination to another table in another destination (DBF)

6. Unable to delete from query if more than one table in query

7. Deleting records with a joined query.

8. delete record in query with join.

9. Deleting records from a join query

10. Deleting records from a join query

11. Delete of a joined query

12. Cannot Delete Records in a Joined Table

 

 
Powered by phpBB® Forum Software