Inner Join Delete in SQL Server 2008?

sql, sql-server, sql-server-2008

Solution

First try to delete `TableB` with that title condition Then delete those records in `TableA`

DELETE FROM TableB
WHERE Id IN 
( SELECT Id FROM TableA WHERE title = 'test')

DELETE FROM TableA
WHERE title = 'test'

Referential Constraints blocks you from deleting rows in `TableA` when you still have reference in `TableB`

Problem

I am trying to join 2 tables together and do a delete on it. ``` DELETE TableA FROM TableA a INNER JOIN TableB b on b.Id = a.Id where title like 'test' ``` The above is what I come up with however I keep getting The DELETE statement conflicted with the REFERENCE constraint I thought if I merge the 2 tables together then I will delete both at the same time and no constraints would be conflicted. Am I missing something in my query?

Original source