0

Trying to create an entry in a table like this:

insert into movie(mvnumb, mvtitle, yearmade, mvtype, noms, awrds, dirnumb)
values ('10111', 'Something' , '2012', 'Action', '5', '2', '10079')

and I get this error

Msg 547, Level 16, State 0, Line 1
The INSERT statement conflicted with the FOREIGN KEY constraint "FK_movie_director". The conflict occurred in database "Assign1W13", table "dbo.director", column 'dirnumb'.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • You have a `FOREIGN KEY` constraint. It seems that there is no director with `dirnumb` of `10079` in `director` table, so this Insert is rejected. – ypercubeᵀᴹ Feb 23 '13 at 17:44
  • possible duplicate of [INSERT statement conflicted with the FOREIGN KEY constraint](http://stackoverflow.com/questions/2965837/insert-statement-conflicted-with-the-foreign-key-constraint) – ypercubeᵀᴹ Feb 23 '13 at 18:00

2 Answers2

1

It means that director id 10079 ( column dirnumb) does not exist in director table.

Omar MEBARKI
  • 647
  • 4
  • 8
0

You can only use that director number if it exists in the director table, so check this first. If it does actually exist, try getting rid of the quotes around the director number. I am assuming you are using SQL Server based on the error message, so the quotes shouldn't be a problem, but for some DBs, they can cause problems around numbers.

jle
  • 9,316
  • 5
  • 48
  • 67