Unable to save foreign keys

I'm trying to setup my foreign keys so I can use them in a VisualStudio projects but I'm getting an error and I can't track down what's causing it.  Can anyone help me with this?

'tbl_departments' table saved successfully
'tbl_people' table saved successfully
'tbl_locations' table saved successfully
'tbl_position' table
- Unable to create relationship 'FK_tbl_position_tbl_departments'.  
The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_tbl_position_tbl_departments". The conflict occurred in database "MyProjectDB", table "dbo.tbl_departments", column 'ID'.

All of my tables have an ID field that is a primary key with Allow Null unchecked.


September 4th, 2015 2:46pm

Hi,

SQL Server always checks data before creating foreign keys. You have departmnets ids in position table which doesnt exist in department table most likely.

  • Proposed as answer by Naomi NEditor Friday, September 04, 2015 3:12 PM
  • Marked as answer by That Web Guy Friday, September 04, 2015 6:55 PM
Free Windows Admin Tool Kit Click here and download it now
September 4th, 2015 2:57pm

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

Other recent topics Other recent topics