Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. problem with relationships

problem with relationships

Scheduled Pinned Locked Moved .NET (Core and Framework)
databasehelpsql-serversysadminquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    xnaLearner
    wrote on last edited by
    #1

    Im using microsoft sql server management studio to create my tables. I previously had the relationships working but I have to go back an re-do them and it is throwing me an error: im trying to do primary key 'person id' in person table with foreign key in holiday table 'person id'556 But when I try to save it I am getting the error: - Unable to create relationship 'FK_Holidays_Person'. The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_Holidays_Person". The conflict occurred in database "holidays", table "dbo.Person", column 'Id'. any idea as to why it won't allow me to update this?

    Richard DeemingR 1 Reply Last reply
    0
    • X xnaLearner

      Im using microsoft sql server management studio to create my tables. I previously had the relationships working but I have to go back an re-do them and it is throwing me an error: im trying to do primary key 'person id' in person table with foreign key in holiday table 'person id'556 But when I try to save it I am getting the error: - Unable to create relationship 'FK_Holidays_Person'. The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_Holidays_Person". The conflict occurred in database "holidays", table "dbo.Person", column 'Id'. any idea as to why it won't allow me to update this?

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      You have at least one record in the holidays table with a person ID which doesn't exist in the person table.

      SELECT DISTINCT PersonID
      FROM Holidays As H
      WHERE Not Exists
      (
      SELECT 1
      FROM Person As P
      WHERE P.ID = H.PersonID
      )


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      X 1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        You have at least one record in the holidays table with a person ID which doesn't exist in the person table.

        SELECT DISTINCT PersonID
        FROM Holidays As H
        WHERE Not Exists
        (
        SELECT 1
        FROM Person As P
        WHERE P.ID = H.PersonID
        )


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        X Offline
        X Offline
        xnaLearner
        wrote on last edited by
        #3

        thank you for the reply, i had to delete all the data in both tables to get it to work

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups