• seshu67 (8/7/2012)


    Can a table have two primary keys

    By absolute definition, no. That's why it's called a "Primary" key and there can only be one primary.

    In all practicality, yes. You can create a UNIQUE constraint on a NOT NULL column and for all practical intent and purposes it works the same way as a Primary Key. It's what some folks call an "AK" or "Alternate Key".

    If this is for an interview, be sure to mention that the PK does NOT have to be the clustered index. You can only have one clustered index.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)