Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 query

Author  Topic 

programer
Posting Yak Master

221 Posts

Posted - 2010-09-16 : 12:36:21
Hi

I have two table:
- tbl_Payments
- tbl_PaymentDetails

Query:
DELETE FROM tbl_Payments
FROM tbl_Payments INNER JOIN
tbl_PaymentDetails ON tbl_Payments.ID = tbl_PaymentDetails.ID

This query deletes the data from the first table.
Data from other tables are not deleted.

Please help how to delete a single query data from the first and second table.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-09-16 : 13:13:07
in your case it can be achieved using ON CASCADE DELETE option on tbl_PaymentDetails

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

programer
Posting Yak Master

221 Posts

Posted - 2010-09-16 : 13:24:11
quote:
Originally posted by visakh16

in your case it can be achieved using ON CASCADE DELETE option on tbl_PaymentDetails

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/





Is there a case for it? On the Internet, I can not find anything suitable.

Or how to achieve it?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-09-16 : 13:28:18
you'll specify it when you create foreign key on tbl_paymentdetails

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -