SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Schema Change on Table with Transactional Replication


Schema Change on Table with Transactional Replication

Author
Message
holidasa
holidasa
SSC Veteran
SSC Veteran (245 reputation)SSC Veteran (245 reputation)SSC Veteran (245 reputation)SSC Veteran (245 reputation)SSC Veteran (245 reputation)SSC Veteran (245 reputation)SSC Veteran (245 reputation)SSC Veteran (245 reputation)

Group: General Forum Members
Points: 245 Visits: 232
SQL Server 2005 SP3
We have multiple databases whose data is replicated to one "main" database. This uses transactional replication (we are not using updatable subscriptions).
Some of the transactionally replicated tables have new columns added to them. (Not all of the replicated tables have been altered, only some.)

There are three publishers and each one has one subscriber--which all target the same database.
Example:
Publisher Subscriber
DatabaseA DatabaseM
DatabaseB DatabaseM
DatabaseC DatabaseM

This is done to allow all of the data to be rolled up to one location and queried.

If I allow replication to replicate DDL changes, then when the first publisher updates the subscriber with the new tables. Fair enough.
However, the other two publishers also have to be updated. When I apply the schema changes to the other two publishers, the distributor agent fails stating column names must be unique (error 2705). The error makes sense as the distributor is trying to apply the DDL changes to the subscriber which already occurred when the first publisher was updated.

I also tried dropping the article from the subscription and publication. This allow me to update the schema at the publishers and the subscriber with no problems. However, when I add the tables back to the publication, replication wants to re-replicate the data from the publishers to the subscriber. The distributor now reports the error 2627 (violation of PK constraint). It is attempting to replicate the data which already exists at the subscriber.

Is there anyway to "tell" the distributor to just assume all of the data is there and only begin replicating new data?

I tried to use different agent profiles to ignore the errors (2705 for the first 'method' and 2627 for the second method) but this does not fully address the issue.
I do not want to delete the data at the subscriber because I do not want to have to re-replicate 60 million records over the WAN.

I would really like to just tell replication to assume the published articles' data already exists at the subscriber and replicate changes beginning now.

I appreciate your assitance.
holidasa
holidasa
SSC Veteran
SSC Veteran (245 reputation)SSC Veteran (245 reputation)SSC Veteran (245 reputation)SSC Veteran (245 reputation)SSC Veteran (245 reputation)SSC Veteran (245 reputation)SSC Veteran (245 reputation)SSC Veteran (245 reputation)

Group: General Forum Members
Points: 245 Visits: 232
In case anyone is wondering, I was able to find a solution for this.
Drop the subscription(s)
Update the schema
Re-create the subscription setting the property @sync_type to 'replication support only'

See the SQL Server BOL information for the sp_addsubscription usage for this property and information when using this value.
Anil KK
Anil KK
Say Hey Kid
Say Hey Kid (705 reputation)Say Hey Kid (705 reputation)Say Hey Kid (705 reputation)Say Hey Kid (705 reputation)Say Hey Kid (705 reputation)Say Hey Kid (705 reputation)Say Hey Kid (705 reputation)Say Hey Kid (705 reputation)

Group: General Forum Members
Points: 705 Visits: 270
Instead of dropping and adding subscriptions, we may also alter the SP_MSins_<ArticleName> sp, in the subscribers by adding a condition at the start of SP, to check if the record exists, return esle proceed. This way it works for managing DML changes, i am wondering if there is any sp like that to manage DDL changes.

Anil Kubireddi
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search