Solved

Foreign Key Constraint Error?

Posted on 2015-01-21
6
73 Views
Last Modified: 2015-01-22
Please see Screenshot for error message.

I understand this error usually. But in this case I'm not sure. I'm basically trying to delete a record from table LKUP_UserAccounts where the PrimaryKey value is 9. The error says it conflicts with the "approvedBy_ID" column in the LKUP_UnitBaseConversions table. That tells me that at least one row in that table contains the value of 9 in the "approvedBy_ID" column. However, when I check the LKUP_UnitBaseConversions table....there are not rows where that value resides in that column. There are actually 3 different columns that could contains that value but in this case, 9 doesn't exist in any of the 3 columns.

What else could it be?

Thanks
Screenshot.JPG
0
Comment
Question by:BlakeMcKenna
  • 2
  • 2
6 Comments
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 40563362
is it a direct referential integrity problem , or is the message coming from the action of a table/view trigger...

can you post the actual delete as coded , and the underlying table structures?
0
 
LVL 49

Accepted Solution

by:
Vitor Montalvão earned 500 total points
ID: 40563955
By the error message you are trying to delete a user account that is referred in the column approvedBy_ID of the table LKUP_UnitBaseConversions, right?
How do you know is the value 9?
0
 

Author Comment

by:BlakeMcKenna
ID: 40564206
I actually stepped thru the code and at the point just before the data was stored, the value wasn't a 9 rather 0 which meant that value didn't reside in the other datatable. So, everything was working as it should....my bad!
0
 
LVL 49

Expert Comment

by:Vitor Montalvão
ID: 40564213
The machine is always right :)
0
 

Author Comment

by:BlakeMcKenna
ID: 40564217
I believe so....thanks for your input!
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Audit has been really one of the more interesting, most useful, yet difficult to maintain topics in the history of SQL Server. In earlier versions of SQL people had very few options for auditing in SQL Server. It typically meant using SQL Trace …
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

740 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