Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2012
    Posts
    1

    Unanswered: Two primary keys in a single table

    • I have a table fields Register_date, Std_ID, course, version, CourseLearningDays, Batch_Time and Trainer_ID
    • HOw to make Register_date and Batch_Time as primary key in the table..
    • please get me code and also mention the necessary datatype for these two fields.
    • And one more do we have datatype called date and time in MS SQL Server

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    CREATE TABLE foo
    ( Register_date            DATE        NOT NULL
    , Std_ID                   INTEGER     NOT NULL
    , course                   VARCHAR(9)  NOT NULL
    , version                  SMALLINT    NOT NULL
    , CourseLearningDays       SMALLINT    NOT NULL
    , Batch_Time               TIME        NOT NULL
    , Trainer_ID               INTEGER     NOT NULL
    , PRIMARY KEY ( Register_date , Batch_Time )
    );
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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