Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2003
    Posts
    5

    Question Unanswered: composite primary key

    How can i implement :
    Foreign key of one table referencing composite primary key of other table?

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Here's a sample of ours....

    Check out BOL though

    Code:
    ALTER TABLE [dbo].[WH_Proof] ADD 
    	 FOREIGN KEY 
    	(
    		[Company_Name],
    		[Tax_Agency_ID],
    		[Region],
    		[Tax_Class],
    		[Sub_Region]
    	) REFERENCES [dbo].[WH_Proof_List] (
    		[Company_Name],
    		[Tax_Agency_ID],
    		[Region],
    		[Tax_Class],
    		[Sub_Region]
    	),
    	 FOREIGN KEY 
    	(
    		[Company_Name],
    		[Tax_Agency_ID],
    		[Region],
    		[Tax_Class],
    		[Proof_Year],
    		[Proof_Period]
    	) REFERENCES [dbo].[Disb_Proof] (
    		[Company_Name],
    		[Tax_Agency_ID],
    		[Region],
    		[Tax_Class],
    		[Proof_Year],
    		[Proof_Period]
    	),
    	 FOREIGN KEY 
    	(
    		[Period_Type]
    	) REFERENCES [dbo].[Period_Type] (
    		[Period_Type]
    	),
    	 FOREIGN KEY 
    	(
    		[Status]
    	) REFERENCES [dbo].[Proof_Status] (
    		[Status]
    	)
    GO
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Nov 2003
    Posts
    5
    can i define the composite foreign key while creating the table?

Posting Permissions

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