Solved

The DELETE statement conflicted with the REFERENCE constraint

Posted on 2011-09-09
3
1,033 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 167 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 333 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 333 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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Suggested Solutions

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

749 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