Solved

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

Posted on 2011-02-27
3
791 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
[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
3 Comments
 
LVL 15

Accepted Solution

by:
derekkromm earned 500 total points
ID: 34993871
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
ID: 34993886
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
ID: 34993898
Great, thanks!
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CentOS Backup Options 3 67
Archiving/Deleting Old E-Mail boxes 4 55
Call to SQL server times out 5 55
Search Text in Views 2 28
Read about achieving the basic levels of HRIS security in the workplace.
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…

751 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