Click here to Skip to main content
15,908,675 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have droped fkey constraint in a table..againg i have to add that..but getting error..pleas help me out..

alter table Tbl_stp_details add constraint FK_Tbl_STP_Details_Tbl_Area_Mst foreign key(C_Area_Code) references tbl_Area_mst(c_code)


error in down..

SQL
Msg 547, Level 16, State 0, Line 1
The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_Tbl_STP_Details_Tbl_Area_Mst". The conflict occurred in database "ADCOCK", table "dbo.Tbl_Area_Mst", column 'C_Code'.
Posted

1 solution

Check, if there is any data in the table Tbl_stp_details column C_Area_Code that is violating Foreign key constraint/referential integrity.

Or, in other words, is there any data in the to-be foreign key C_Area_Code of table Tbl_stp_details that is not in its primary table's tbl_Area_ms column C_Code

If yes, then you need to add that data in the tbl_Area_ms table first and then you can use it in Tbl_stp_details
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900