Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 87
  • Last Modified:

Foreign Key Constraint Error?

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
BlakeMcKenna
Asked:
BlakeMcKenna
  • 2
  • 2
1 Solution
 
LowfatspreadCommented:
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
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
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
 
BlakeMcKennaAuthor Commented:
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
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
The machine is always right :)
0
 
BlakeMcKennaAuthor Commented:
I believe so....thanks for your input!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now