Solved

The DELETE statement conflicted with the REFERENCE constraint

Posted on 2011-09-09
3
1,022 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

12 Experts available now in Live!

Get 1:1 Help Now