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. Database & SysAdmin
  3. Database
  4. Error in SQL Server 2005

Error in SQL Server 2005

Scheduled Pinned Locked Moved Database
databasehelpsql-serversysadmintools
5 Posts 3 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.
  • K Offline
    K Offline
    ksaw123
    wrote on last edited by
    #1

    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.

    B 1 Reply Last reply
    0
    • K ksaw123

      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.

      B Offline
      B Offline
      Blue_Boy
      wrote on last edited by
      #2

      Check datatypes fields in relations tables


      I Love SQL

      K 1 Reply Last reply
      0
      • B Blue_Boy

        Check datatypes fields in relations tables


        I Love SQL

        K Offline
        K Offline
        ksaw123
        wrote on last edited by
        #3

        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.

        R 1 Reply Last reply
        0
        • K ksaw123

          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.

          R Offline
          R Offline
          Rami Said Abd Alhalim
          wrote on last edited by
          #4

          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

          K 1 Reply Last reply
          0
          • R Rami Said 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

            K Offline
            K Offline
            ksaw123
            wrote on last edited by
            #5

            Thanks a lot. That was right. I was looking in each coulmn exept to this coulmn. Thanks again.

            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