Solved

The DELETE statement conflicted with the REFERENCE constraint

Posted on 2011-09-09
3
1,026 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
  • 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:RQuadling
RQuadling 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:RQuadling
RQuadling 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

867 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now