Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
hi!table1 and table2 have a one to many relationship, linked on sourceIDi need to delete all records from both tables, where the source status(stored in table 1) is "P"
delete from Table2 t2, Table1 t1 where t1.sourceid = t2.sourceid and t1.sourceStatus = 'P'
I don't know if it is possible to delete from two tables ion one step (without cascading delete or so...).I would do it in two steps.First the child tabledelete t2from table2 t2join table1 t1 on t1.sourceid=t2.sourceidwhere t1.sourceStatus='P'Step 2delete table1 where sourceStatus='P'Is it what you want?No, you're never too old to Yak'n'Roll if you're too young to die.
webfred
Master Smack Fu Yak Hacker
8781 Posts
Posted - 2012-01-19 : 10:16:28
No, you're never too old to Yak'n'Roll if you're too young to die.