Results 1 to 2 of 2

Thread: Composite primary keys

  1. #1
    Join Date
    Nov 2002
    Location
    Sydney
    Posts
    1

    Composite primary keys

    Im having some troubles with creating a table with SQL that has a composite key. The two fields im trying to have as composite keys are user_id and address_type within the address table. Any help with this would be fanastic.
    Thanks in advance
    Pete

  2. #2
    Join Date
    Sep 2002
    Location
    Amsterdam
    Posts
    53
    After creating your table add the PK like this:

    ALTER TABLE [dbo].[addresstable] ADD
    CONSTRAINT [PK_ACCTIONCODE] PRIMARY KEY CLUSTERED
    ( [user_id ], [address_type ] )

Posting Permissions

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