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)
 One DELETE sql statement to delete from two tables

Author  Topic 

smsayami
Starting Member

1 Post

Posted - 2007-08-12 : 02:52:38
I am trying to write one sql statement that deletes from two tables. Is it possible ? If yes, any thoughts ?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-12 : 03:25:26
No, I do not think that is possible with one T-SQL statement.
You can however manage it with a TRIGGER, but this is not something I recommend.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2007-08-12 : 20:39:50
Look up cascading deletes. This is possible if you have relationships setup with cascading deletes.

You could also write a stored procedure that when you called delete it would have the code to delete from multiple tables.
Go to Top of Page
   

- Advertisement -