Primar key

  • Can I add a primary key constraint after data is loaded is loaded into the table?If not then how can I ensure that the data from now on is unique?

    Thanks.

  • Yes, you can add a PK after data has been loaded into the table.

    You can also use a unique contstraint to check if data is unique.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Assuming that earlier loaded data has duplicates which is fine and now I want to upload only duplicate data.Any query would help.Thanks!1

  • Assuming that earlier loaded data has duplicates which is fine and now I want to upload only unique

    data.Any query would help.Thanks!1

  • gsaini 95591 (2/26/2014)


    Assuming that earlier loaded data has duplicates which is fine and now I want to upload only unique

    data.Any query would help.Thanks!1

    This could be realized with a unique filtered index.

    Create Filtered Indexes

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • I don't think you can add primary key on the column which has duplicates values already

  • Sushil Dwivedi (2/27/2014)


    I don't think you can add primary key on the column which has duplicates values already

    Indeed. That's why I suggested an unique filtered index.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply