Error in SQL Server 2005
-
I got this error and I don;t know how to solve it even thought my parameters are matching. 'DHS_CostCenter' table saved successfully 'DHS_Employee' table - Unable to create relationship 'FK_DHS_Employee_DHS_CostCenter'. The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_DHS_Employee_DHS_CostCenter". The conflict occurred in database "DHS2", table "dbo.DHS_CostCenter", column 'CostCenterID'. User canceled out of save dialog (MS Visual Database Tools). Thanks for your help.
-
I got this error and I don;t know how to solve it even thought my parameters are matching. 'DHS_CostCenter' table saved successfully 'DHS_Employee' table - Unable to create relationship 'FK_DHS_Employee_DHS_CostCenter'. The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_DHS_Employee_DHS_CostCenter". The conflict occurred in database "DHS2", table "dbo.DHS_CostCenter", column 'CostCenterID'. User canceled out of save dialog (MS Visual Database Tools). Thanks for your help.
-
Thank you for your answer. However, I am sure I am right unless I don't understand what do you mean. This is what I have: I have a table called DHS_CostCenter that has these columns: 1- CostCenterID (Primary Key) int Not Null. 2- CostCenterName varchar(70) Not Null. The other table called DHS_Employee that has these columns: 1- BadgeNum int Not Null. 2- Name varchar(50) Not Null. 3-CostCenterID int Not Null. 4- DateFrom smalldatetime Not Null. 5- DateTo smalldatetime Not Null. I made a relationship between them (the primary key is CostCenterID that is in DHS_table and the Foreign Key is in DHS_Employee). After that when I want to save it, I got this error. I am looking for an answer.
-
Thank you for your answer. However, I am sure I am right unless I don't understand what do you mean. This is what I have: I have a table called DHS_CostCenter that has these columns: 1- CostCenterID (Primary Key) int Not Null. 2- CostCenterName varchar(70) Not Null. The other table called DHS_Employee that has these columns: 1- BadgeNum int Not Null. 2- Name varchar(50) Not Null. 3-CostCenterID int Not Null. 4- DateFrom smalldatetime Not Null. 5- DateTo smalldatetime Not Null. I made a relationship between them (the primary key is CostCenterID that is in DHS_table and the Foreign Key is in DHS_Employee). After that when I want to save it, I got this error. I am looking for an answer.
Hi CanadianBoy: When you made a relationship between them (the primary key is CostCenterID that is in DHS_table and the Foreign Key is in DHS_Employee). You must compare between data PK and FK i think found data in FK not Found in PK Example : Table DHS_CostCenter ---------------------------------------------- CostCenterID CostCenterName 1 'Cost1' ---------------------------------------------- 2 'Cost2' ---------------------------------------------- 4 'Cost4' ---------------------------------------------- Table DHS_Employee ---------------------------------------------- BadgeNum Name CostCenterID DateFrom DateTo ----------------------------------------------------------- 1 'badge1' 1 1/1/2007 2/2/20007 ----------------------------------------------------------- 2 'badge1' 3 1/1/2007 2/2/20007(This Record have problem because CostCenterID 3 not found in table DHS_CostCenter) ---------------------------------------------------------- 3 'badge1' 4 1/1/2007 2/2/20007 ---------------------------------------------- best :)regard Rami Abd Alhalim
-
Hi CanadianBoy: When you made a relationship between them (the primary key is CostCenterID that is in DHS_table and the Foreign Key is in DHS_Employee). You must compare between data PK and FK i think found data in FK not Found in PK Example : Table DHS_CostCenter ---------------------------------------------- CostCenterID CostCenterName 1 'Cost1' ---------------------------------------------- 2 'Cost2' ---------------------------------------------- 4 'Cost4' ---------------------------------------------- Table DHS_Employee ---------------------------------------------- BadgeNum Name CostCenterID DateFrom DateTo ----------------------------------------------------------- 1 'badge1' 1 1/1/2007 2/2/20007 ----------------------------------------------------------- 2 'badge1' 3 1/1/2007 2/2/20007(This Record have problem because CostCenterID 3 not found in table DHS_CostCenter) ---------------------------------------------------------- 3 'badge1' 4 1/1/2007 2/2/20007 ---------------------------------------------- best :)regard Rami Abd Alhalim