Groups | Blog | Home
all groups > sql server programming > november 2004 >

sql server programming : Delete Statement and related records in another table?


John Rugo
11/9/2004 11:06:18 PM
Hi All,
Is there a simple way of deleting records in one table and also those tables
related in another table.

Create Table Table1
(PID VarChar(50),
RID VarChar(50))

Create Table Table2
(RID VarChar(50))
---------------------------

DELETE FROM Table1
WHERE PID = @pidValue

/*Now I want to delete the records in Table2 that are related by the RID
column in both.*/

I know this can be done but I'm really tired and my head hurts :(
Any Ideas would be greatly appreciated.

Thanks,
John.



John Rugo
11/10/2004 7:18:07 AM
There are no keys involved here. I would like to programmatically delete
"dynamically" referenced columns if possible.

[quoted text, click to view]

Roji. P. Thomas
11/10/2004 12:21:43 PM
See ON DELETE CASCADE in BOL

--
Roji. P. Thomas
Net Asset Management
https://www.netassetmanagement.com


[quoted text, click to view]

AddThis Social Bookmark Button