Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1061
  • Last Modified:

The DELETE statement conflicted with the REFERENCE constraint

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
Jeff S
Asked:
Jeff S
  • 2
3 Solutions
 
LowfatspreadCommented:
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
 
Richard QuadlingSenior Software DeveloperCommented:
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
 
Richard QuadlingSenior Software DeveloperCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now