Trying to add FK_constraints but could not understand what happened?

ALTER TABLE [PartyAddressHistory] ADD CONSTRAINT [FK_PartyAddressHistory_Address] FOREIGN KEY(AddressID)REFERENCES [Address](AddressID)----N
sg 547, Level 16, State 0, Line 1
The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_PartyAddressHistory_Address". The conflict occurred in database "test1MDM", table "dbo.Address", column 'AddressID'.
ALTER TABLE [PartyAddress] ADD CONSTRAINT [FK_PartyAddress_Address] FOREIGN KEY(AddressID)REFERENCES [Address](AddressID)----N
Msg 547, Level 16, State 0, Line 1
The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_PartyAddress_Address". The conflict occurred in database "test1MDM", table "dbo.Address", column 'AddressID'.
ALTER TABLE [PartySport] ADD CONSTRAINT [FK_PartySport_Leagues] FOREIGN KEY(LeagueID)REFERENCES [Leagues](LeagueID)----N
Msg 547, Level 16, State 0, Line 1
The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_PartySport_Leagues". The conflict occurred in database "test1MDM", table "dbo.Leagues", column 'LeagueID'.

Well, the error is actually clear. It means that PartyAddressHistory table has values in the AddressID column which are not in the Address table.
You have the same problem in the PartyAddress table and PartySport has a similar problem.
To find bad rows try
select * from PartyAddress PA where not exists (select 1 from Address A where A.AddressID = PA.AddressID) -- similar statements for other tables.
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles

Similar Messages

Maybe you are looking for

  • My mid 2009, 17inch Macbook Pro will not switch on unless it is physically hot. I have to heat it up with a hairdryer to switch it on.

    Hey guys, my macbook doesn't switch on unless it is physically hot. I use a hairdryer to do this (I know it's bad but i have no other option, i'm not looking for a lecture on why it's bad to do this.) Once it is hot it still takes a long time to boot

  • What's wrong with this button code

    Dear All, I am trying to set up a button handler for many buttons rather just one. The intention of this code is to say if I press Load1 to Load40 that button and only that button's alpha should change to 50%. This code makes them all 50% alpha when

  • Best export type for web viewing

    I just bought a Eyetv and recoreded me playing halo 2 on my 360. i was wondeirng what the best export for posting something on youtube would be. the choices i have are, quicktime movie, mpeg-4, h.264,divX avi, windows media, AAc audio and apple lossl

  • Issues with BDLS for table /SAPAPO/TSTROBJR after system refresh

    Hi, After a recent refresh of our QA system from the Production system, when we are running BDLS for the table /SAPAPO/TSTROBJR to convert the logical system from Prod to QA, it's not allowing us to make the change. Error message reads: /SAPAPO/TSTRO

  • Duplicate songs in library

    Hello I just installed ITunes and when it added my songs to my library it made duplicates of most of the songs, how do I get rid of the duplicates without going through and deleting each one individually. Also why did it make dups of most of my songs