I get a error The INSERT statement conflicted with the FOREIGN KEY constraint on my application server which uses SQL

Hi All,

I get the below error on the event log of my application server which uses SQL database.

Details: RuleId:a811dcbc-4c5b-d9de-592b-f01e17fc0e9a. HealthServiceId:a5f70248-b545-4d35-7c84-e7aa87610ee4. The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Alert_BaseManagedEntity". The conflict occurred in database "OperationsManager", table "dbo.BaseManagedEntity", column 'BaseManagedEntityId'.
The statement has been terminated.RuleId:a811dcbc-4c5b-d9de-592b-f01e17fc0e9a. HealthServiceId:a5f70248-b545-4d35-7c84-e7aa87610ee4. The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Alert_BaseManagedEntity". The conflict occurred in database "OperationsManager", table "dbo.BaseManagedEntity", column 'BaseManagedEntityId'.
The statement has been terminated..

================

Details: RuleId:a811dcbc-4c5b-d9de-592b-f01e17fc0e9a. HealthServiceId:a5f70248-b545-4d35-7c84-e7aa87610ee4. The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Alert_BaseManagedEntity". The conflict occurred in database "OperationsManager", table "dbo.BaseManagedEntity", column 'BaseManagedEntityId'.
The statement has been terminated..

=========================

I am not an expert in SQL. Does any one know what this means and how do i solve it ?

July 31st, 2015 12:08pm

Hello,

It's pretty easy: There is a foreign key constraint on the table and the app tries to insert an ID into column 'BaseManagedEntityId' which don't exists in the related primary key table.

Free Windows Admin Tool Kit Click here and download it now
July 31st, 2015 12:19pm

How are you trying to insert data into that BaseManagedEntityId column? It should be picked from some sort of the drop-down referencing the parent table or otherwise it should be set to NULL (not 0).
July 31st, 2015 12:29pm

Hi Olaf / Naomi

Thanks for your replies.

I am bit beginer in SQL.

Can you help me in achieving this ?

Do you say i need to find the actual location where BaseManagedEntityId is and create a table so the application can store it right ?

The application writes the data,No users manually update the data in the SQL database.
Free Windows Admin Tool Kit Click here and download it now
July 31st, 2015 1:02pm

If you have access to SSMS, find that table dbo.BaseManagedEntity and post here its structure (right click in SSMS, script table as create).

Then also search your application and find out where and how you're inserting rows into that table.

It sounds like that table has a key referencing itself (may be it's an organization type of table, say, Employee that has a column referencing their managers) and you're trying to insert 0 into that column which is not allowed. But that's my guess, you need to script that table and if it has triggers, script them as well.

July 31st, 2015 1:31pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics