?
Solved

The DELETE statement conflicted with the REFERENCE constraint

Posted on 2011-09-09
3
Medium Priority
?
1,040 Views
Last Modified: 2012-05-12
I need to delete a Visit Transaction and getting this message -

Msg 547, Level 16, State 0, Line 1
The DELETE statement conflicted with the REFERENCE constraint "FK_Transactions_VisitTransactionsId". The conflict occurred in database "pc", table "dbo.Transactions", column 'VisitTransactionsId'.
The statement has been terminated.
DELETE FROM visittransactions 
where VisitTransactionsId = '592167'

Open in new window

0
Comment
Question by:Jeff S
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 50

Accepted Solution

by:
Lowfatspread earned 668 total points
ID: 36511541
to delete the visittransaction you must first delete its children on the transaction table...

the referrential constraint exists to prevent orphanned transactions from occurring.

check your system documentation

0
 
LVL 40

Assisted Solution

by:Richard Quadling
Richard Quadling earned 1332 total points
ID: 36511544
The Transactions table has a reference to the VisitTransaction table.

You need to delete the Transactions for 591267 first otherwise they will become orphaned records from the VisitTransaction table.
0
 
LVL 40

Assisted Solution

by:Richard Quadling
Richard Quadling earned 1332 total points
ID: 36511556
You can set the relationship to cascade deletes, so deleting a parent row will delete all the associated child rows in the child table.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question