ALTER TABLE breaks replication

  • I have a table-article being replicated as part of a publication that replicates DDL commands. Historically, executing ALTER statements on replicated tables has not caused any problems.

    However, I recently executed the following ALTER:

    ALTER TABLE my_table ADD my_column INT NULL DEFAULT(0)

    I immediately started receiving the following error on one subscriber:

    Procedure or function 'sp_MSupd_mytable' expects parameter '@pkc1', which was not supplied.

    And this error on another subscriber:

    rocedure or function 'sp_MSins_mytable' expects parameter '@c7', which was not supplied.

    I was under the impression the sp_MS-stored procs would update automatically to reflect schema changes and that there shouldn't be any problem if the Log Reader is processing changes as it should. Anything jump out as the specific cause of this problem? Let me know if I can provide any other information that would help.

    Thanks

  • The article has "Copy check contraints" set to False. This ALTER would certainly add a constraint to default new values to 0. It seems to me that the Log Reader should just end up picking up the ALTER and applying the change on subscribers, resulting in a new constraint on the downstream DBs. Just thinking out loud about the possibility of a conflict between the article properties and what the subscribed servers would end up doing.

  • If you make Schema changes to Publisher they are propagated to Subscriber by default, unless set otherwise while creating replication.

    So as you said, you can wait if it resolves the issue by self, else you can manually modify the SPs in question on the subscriber DB.

  • Just observed one more thing. your default in not named. Always create named defaults if you are using replication. It creates issue if you drop or alter defaults.

  • Check the setting of Copy INSERT, UPDATE, DELETE stored procedures for this article should be set to true.

  • I don't think the problem would "resolve itself" unless I had manually modified those SPs. Strangely enough "Copy INSERT, UPDATE and DELETE stored procedures" is set to True so I'm not sure why they didn't update automatically

  • I did read here http://msdn.microsoft.com/en-us/library/ms151870.aspx that naming the constraint is recommended. Just wish I knew if that is the cause of the original problem. Thanks for your replies

  • No. Named constrains will cause problem only when they are either altered or deleted at publisher.

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

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