How to declare two primary keys in a table?

Discussion in 'Databases' started by rajanrufus, Aug 27, 2013.

  1. #1
    Hai,
    After a long time i have came back to this forum and brought a question for you all guys.
    Actually i am learning sql of my own and doing exercises in it. Now i have to know that 'How to declare two primary keys in a table?'

    Thank you,
     
    rajanrufus, Aug 27, 2013 IP
  2. felomeno

    felomeno Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #2
    It would be better if you tell me what do you need to do with the two primary keys... but, this should do it

    alter table TABLE_NAME add constraint PK_KEY_NAME primary key nonclustered (Column1,Column2)
    Code (markup):
    Column1 and Column2 will be added as primary keys.
    Hope it helps. ;)
     
    felomeno, Aug 27, 2013 IP