I have a webapp that connects to a database with several tables.
For testing purposes, I need to delete one of the rows in a table. I'm using the following line:
delete from EventsTable where Name = 'John's Party'
However, when running this I'm getting the below error message:
The DELETE statement conflicted with the REFERENCE constraint "FK_dbo.People_dbo.EventsTable_EventId". The conflict occurred in database "PlannerDatabase", table "dbo.People", column 'EventId'.
This, I assume, is happening because of the foreign key being tied to a primary key in the EventsTable but my question is:
Is there any way to, with the least amount of SQL code possible, delete "John's Party" from the EventsTable and all rows related to that party in the rest of tables?
I'm using SQL Server Management Studio 2012.