Results 1 to 2 of 2
  1. #1
    Join Date
    May 2004
    Location
    Cleveland Ohio Area
    Posts
    3

    Lightbulb Unanswered: Two primary keys

    In access you can have two fields that are primary keys with one or the other repeating as long as the combination is not repeated.
    i.e.
    key1 key2
    200410 12345
    200410 12346
    200410 12588
    etc for all 200410 there can not be a repeat of any value of key 2

    is there a way to have this dual key in MSSQL
    Last edited by khall1; 05-17-04 at 15:01.

  2. #2
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    Yes you can have a composite primary key in MS SQL also ...
    CREATE TABLE [sales] (
    [stor_id] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
    [ord_num] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
    [ord_date] [datetime] NOT NULL ,
    [qty] [smallint] NOT NULL ,
    [payterms] [varchar] (12) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
    [title_id] [tid] NOT NULL ,
    CONSTRAINT [UPKCL_sales] PRIMARY KEY CLUSTERED
    (
    [stor_id],
    [ord_num],
    [title_id]
    ) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    Get yourself a copy of the The Holy Book

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

Posting Permissions

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