Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2010
    Posts
    6

    Unanswered: Foreign key error

    Create Table Branche
    (
    BranchID varchar(50),
    City varchar(70),
    No varchar(20),
    Street varchar(100),
    PostalCode varchar(40)

    Constraint PK_Branch Primary Key(BranchID)

    ) -----------End Brannch Table




    -----------Multivalued attribute

    Create Table Branch_Contact
    (
    BranchID varchar(50),
    ContactNumber varchar(25)

    Constraint PK_Contacts Primary key(BranchID,ContactNumber)
    Constraint FK_BranchContact Foreign key(BranchID)References Branche(BranchID)

    )


    hey anyone please help me. Iam trying to create the both table which is given above. But when a execute query i got the following error

    Msg 1753, Level 16, State 0, Line 1
    Column 'Branche.BranchID' is not the same length as referencing column 'Branch_Contact.BranchID' in foreign key 'FK_BranchContact'. Columns participating in a foreign key relationship must be defined with the same length.
    Msg 1750, Level 16, State 0, Line 1
    Could not create constraint. See previous errors.

  2. #2
    Join Date
    Nov 2004
    Posts
    1,427
    Provided Answers: 4
    Are you sure you have pasted the EXACT code that fails in your environment? On MSSQL 2008 it passes flawlessly.
    With kind regards . . . . . SQL Server 2000/2005/2012
    Wim

    Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
    Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •