简体   繁体   中英

Invalid Object Merge Replication

I am sitting with a problem.

I added a new table to my replicated DB and updated a view to include this table.

When the replication ran an invalid object error was thrown out due to the view trying to replicate, but the table was not replicated to the subscribers.

I updated the Article replication sequence to ensure the table replicated prior to the view with

sp_changemergearticle

I ran the Snapshot again and the Table was included as an article as expected.

When I ran the replication I still get the Invalid Object Error.

I can not afford to reinitialize the subscriptions as the risk of data loss is to great.

Any help will be appreciated.

Adding an article involves adding the article to the publication, creating a new snapshot for the publication, and synchronizing the subscription(s) to apply the schema and data for the newly added article. After generating a new snapshot the distribution/merge agent will copy the schema and data for the newly added article to the Subscriber(s).

I highly recommend doing a test in a self made environment, once you've gotten it working in a lower or self environment, move the fix to production. Take a backup before doing this, see if you can do this during maintenance hours, and you can do a select insert into other tables if you need additional backup assistance.

Source

More information

Was the table and view added to the subscriber after the snapshot? Did you add the same table and view to the publisher? I am trying to see where you are at. It sounds like you replicated out a view that referenced a table that did not exist at the subscriber. The steps below will work if you have updated the view at the subscriber and at some point later updated the publisher - out of sync article.

  1. Open the view definition at the Publisher.
  2. Copy the view definition.
  3. Navigate to the Subscriber.
  4. Execute the View definition obtained from the publisher in step 2 as an alter statement.
  5. The next time the agent runs it should clear the error as the views are again identical.

It sounds like the safest bet would be to add both the table and view as articles on the publisher and restart the snapshot, pull/push the latest.

So what ended up working was to manually create the table that was missing in each subscriber.

I just created the Schema with no data, the replication kicked off and did the rest.

The Views was already identical thus reverting to the publisher view was not possible.

Very strange.

Thank you for your assistance everyone!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM