Solved

The DELETE statement conflicted with the REFERENCE constraint....

Posted on 2011-02-27
3
786 Views
Last Modified: 2012-05-11
Ran the command: DELETE FROM [dbo].[USERS]

Got the result:
Msg 547, Level 16, State 0, Line 2
The DELETE statement conflicted with the REFERENCE constraint "FK__Institute__cd_ca__541767F8". The conflict occurred in database "Nova", table "dbo.Institute", column 'cd_userlist'.
The statement has been terminated.


How can I fix this? I need to delete the data inside the table USERS.

0
Comment
Question by:John86a
3 Comments
 
LVL 15

Accepted Solution

by:
derekkromm earned 500 total points
Comment Utility
For every user you want to delete from dbo.Users, you'll have to delete any rows in dbo.Institute where it is referenced in column cd_userlist

delete from dbo.Institute where cd_userlist in (select <id> from dbo.users)
delete from dbo.Users
0
 
LVL 50

Expert Comment

by:Lowfatspread
Comment Utility
there is referential integrity between the users table and the institute table

such that a user identified on the institute table must exist on the user table....

you need to resolve what you will do with the institute table rows for the users that you intend to delete first....

this type of constraint in "general" implies that it was not considered a "valid business process" to allow users once established to be removed... (there are lots of legal requirements in many jurisdictions which mean it becomes difficult to allow data to be removed , are you certain you are required/allowed to remove your user data?)  you need to check with your business analysts as to what steps should be taken.

0
 

Author Closing Comment

by:John86a
Comment Utility
Great, thanks!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 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

11 Experts available now in Live!

Get 1:1 Help Now