By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,410 Members | 1,626 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,410 IT Pros & Developers. It's quick & easy.

The INSERT statement conflicted with the FOREIGN KEY constraint

P: 13
Hi

i have two tables

1- Person
2- Account

In Account table i have key accountID which is a FK in Person table.

when i run the insert query as


insert into

Person(FirstName2)

values ('waq')

as i did not enter any data for account field so it gives me the eror:


The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Person_Account". The conflict occurred in database "abc", table "dbo.Account", column 'AccountId'.

can somebody help me with that as i want to insert the valuse in Person table whether i have accountID or not

Thanx
Nov 20 '09 #1

✓ answered by ssnaik84

since, you are having FK of AccountID in Person table, you must have related record in Account table.
I suggest you to insert a default record into Account table and use it's ID (AccountID) into Person table as default.

Share this Question
Share on Google+
1 Reply


ssnaik84
100+
P: 149
since, you are having FK of AccountID in Person table, you must have related record in Account table.
I suggest you to insert a default record into Account table and use it's ID (AccountID) into Person table as default.
Nov 20 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.