primary key non clustered index

Chaitanya Kiran 616 Reputation points
2022-04-06T23:56:24.66+00:00

I have a table with columns ID, Name, City, State, SSN, Phone. I have created a clustered index on ID column. I created non-clustered index on SSN column. Now, can I create primary key on the SSN column?

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
9,725 questions
0 comments No comments
{count} votes

Accepted answer
  1. AmeliaGu-MSFT 13,896 Reputation points Microsoft Vendor
    2022-04-07T02:10:23.147+00:00

    Hi ChaitanyaKiran-2787,

    Yes. But please note that A table can contain only one PRIMARY KEY constraint. Any relationships to the existing primary key must be deleted before the new primary key can be created.
    Please check https://learn.microsoft.com/en-us/sql/relational-databases/tables/create-primary-keys?view=sql-server-ver15 for more details.

    Best Regards,
    Amelia


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Naomi 7,076 Reputation points
    2022-04-07T01:33:52.2+00:00

    Yes, primary key doesn't have to be clustered, it just has to be unique.

    0 comments No comments