Source table has primary key and should I need to create in destination table

red 21 Reputation points
2020-08-25T18:07:48.893+00:00

Hi,

I am loading the data from source table to destination table where primary key exists on the source table. My question is do I need to create the primary key in destination table as well?

Thanks!

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,625 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Erland Sommarskog 110.4K Reputation points MVP
    2020-08-25T22:06:06.6+00:00

    I think you should. But "need"? I have no idea of the context where this is happening. But if you don't create a PK, and you copy some rows twice, you will have a mess to sort out.

    0 comments No comments

  2. MelissaMa-MSFT 24,196 Reputation points
    2020-08-26T01:56:47.657+00:00

    Hi @red ,

    I found more details about your reqirement in another forum.

    I need to create a incremental load from source to destination table for reporting needs. We dont have leverage to access source table for all our needs. To be precise I will jst inserting the new records thats comes into source table on daily basis and load into destination table only respective one day records – red 7 hours ago

    Since you would like to create a incremental load from source to destination table, it is strongly recommended for you to create primary key in destination table as well so that both source and destination tables could have the same schema.

    Besides, you could also consider to use SSIS to perform Incremental Load because it could compare the destination table against the source data based on Id or Date Stamp or Time Stamp.

    Please refer more details in below link:
    Incremental Load in SSIS

    If the response is helpful, please click "Accept Answer" and upvote it.

    Best regards
    Melissa

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.