Groups | Blog | Home
all groups > sql server replication > august 2007 >

sql server replication : 'IGNORE_DUP_KEY' is not a recognized ALTER TABLE option.


Glitchbane NO[at]SPAM gmail.com
8/14/2007 10:48:45 PM
I have set up a simple transactional replication that includes
specified columns in one table. One of those columns is used in a
unique key with the ignore_dup_key option set to 'on'. When I tried
to get the replication started, it fails with this error:
'IGNORE_DUP_KEY' is not a recognized ALTER TABLE option.

I looked at the generated script that creates the unique key that is
on one of the columns of the table. Although the key on the original
table was scripted as ... WITH IGNORE_DUP_KEY=ON... the script that
SQL generates for the replication's initial snapshot is this:

ALTER TABLE [dbo].[PostHeap] ADD CONSTRAINT [PK_PostHeap_new] PRIMARY
KEY CLUSTERED ([PostID]) WITH IGNORE_DUP_KEY
go

Thus the error gets generated.

My question is, how can I get around this? I can't just change the
script because when I restart the synchronization, the script is
regenerated.

All help greatly appreciated,

Sheila
Hilary Cotter
8/15/2007 12:00:00 AM
Could you use a post snapshot script to alter the table for this?

Note that I don't really understand why you are using this as if the
subscriber is a mirror of the publisher this constraint will be enforced at
the publisher and duplicate values will never come from the publisher to the
subscriber.

--
relevantNoise - dedicated to mining blogs for business intelligence.

Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html

Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
[quoted text, click to view]


8/16/2007 11:57:04 PM
post snapshot scripts are of no help here, and I can't designate the
constraint(s) as Not For Replication because they are table
constraints, not column constraints.

In an attempt to skirt the issue I have tried a lot of things, but I
am confounded by the current status of my latest idea-- I have created
an indexed view on the table in question, and have set up replication
on the indexed view.

The initial snapshot worked perfectly, and I have seen absolutely no
errors on the replication, but when I insert more rows into my
underlying table, they do not seem to be getting replicated through to
the destination view.

(btw, you're right, I don't need the unqiue or ignore_dup_key on the
destination table, but the primary key is required on the source
table, and it is defined with the ignore_dup_key so I am stuck with
it).

Any ideas on that?

Thanks,
Sheila

[quoted text, click to view]
AddThis Social Bookmark Button