Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 creating tables

Author  Topic 

somu210
Starting Member

1 Post

Posted - 2013-03-13 : 09:35:16
hi

i am created two tables countries,states,in countries tables i took 10 values.in state table i entered 12 values but the problem is it is executed only for ten values after that it showing an error.The error is

Msg 547, Level 16, State 0, Line 4
The INSERT statement conflicted with the FOREIGN KEY constraint "FK__States__State_Id__21B6055D". The conflict occurred in database "MYDEMO", table "dbo.Countries", column 'Country_Id'.

Thanks in Advance
somun

somun

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-03-13 : 10:12:49
you need to make sure the countryid value you enter for state table is one that exists in country table otherwise you will get the specified error.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -