Hello,
When I configured replication for a table with PK, there were duplicate entries for same table on subscriber and we had no idea where they were coming from. We also noticed unique non-clustered index was created for column with PK.
Situation was were tight, we broke the replication, truncated table on SUB, manually create unique key and then created new publication and configure same to truncate table on subscriber (SUB) - initialized the replication and it worked.
Let's say we are trying to replicate below table:
CREATE TABLE [dbo].[Test_table100](
[id] [int] IDENTITY(1,1) PRIMARY KEY NONCLUSTERED,
[NAME] [varchar](40) NOT NULL,
[Address] [varchar](40) NOT NULL)
Unique Non-clustered index would be created on Id column and if we manually create clustered index on name column. what would be sequence of events while replicating this table. Per default setting for publication, unique key constraint are set to replicate
but non-clustered indexes are not. I noticed NCI was created on SUB.
1. Distribution agent will start bulk copying the data in the table on SUB.
2. Once completed, Primary key would be created
3. Non-clustered indexes are created, if publication is configured to do so.
4. Changes made to table in question on publisher (PUB), during snapshot generation and distribution are applied.
I would appreciate if you could shed light on below points.
1. Why is constraint disabled during snapshot generation as shown in below screenshot ?
2. When my table on PUB got PK on it, how come there can be duplicate records on SUB ?
3. Have you come across any issues while replicating table with PK and NCI on same column ?
4. Does it matter what all indexes are available on table during snapshot generation ?
Thank you for your time !