Creating Foriegn Key

  • I am trying to create foriegn key but getting the error

    USE TestDB

    GO

    ALTER TABLE [TableA]

    ADD CONSTARINT FK_MyTest FOREIGN KEY

    (

    [ID],[Name],[DOB]

    )

    REFERENCES [TableB]

    (

    [ID],[Name],[DOB]

    )

    GO

    Error Message

    Server: Msg 4902, Level 16, State 1, Line 2

    Cannot alter table 'TableA' because this table does not exist in database 'TestDB'

    Server: Msg 8140, Level 16, State 1, Line 2

    More than one key specified in column level FOREIGN KEY constraint, table 'TableA'.

    Any Help Please.

    RS.

     

  • First off, I'm assuming that TableA exists

    Can you post the DDL for the columns of the two tables?

     

    AucklandSQL User Group
    Independent SQL Server Consultant
    SQL Server MVP

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply