Solved

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

Posted on 2011-02-27
3
790 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
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Connecting to multiple databases to create a Dashboard 5 48
Database Design Dilemma 6 58
Re-appearing SQL Server Agent jobs 7 30
Negative isnull? 3 15
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…
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
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…

828 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