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
 General SQL Server Forums
 New to SQL Server Programming
 Deleting frm multiple tables at a time

Author  Topic 

hotshot_21
Yak Posting Veteran

97 Posts

Posted - 2007-01-10 : 07:06:34
I have 3 tables . iwant to delete rows from all the three tables at same time using single statement.All the 3 tables have a unique column which will be supplied ny the user.
DELETE FROM T1,T2,T3 WHERE column1='1'
how do i do it.

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2007-01-10 : 07:13:22
I suppose you could put a trigger on T1 that will delete from t2 and t3 on delete.

You can see how to do this by reading up in Books OnLine - Look for "trigger"

Duane.
Go to Top of Page

hotshot_21
Yak Posting Veteran

97 Posts

Posted - 2007-01-10 : 07:15:37
if i don't want to use trigger is there any other way
Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2007-01-10 : 07:22:57
No


Duane.
Go to Top of Page

madhuotp
Yak Posting Veteran

78 Posts

Posted - 2007-01-10 : 08:19:15
in such situation u should put all these three delete stateemnt in a Begin Tran and RollBack/Commit tran. sothat it either delete data from all the three tables or none


Madhu
Go to Top of Page
   

- Advertisement -