Sql-server – Indexed view doesn’t exist on the subscriber

replicationsql serversql-server-2008-r2sql-server-2012transactional-replication

I am configuring transactional replication in SQL Server. The subscription is configured as push from 2008R2 publisher (distributor is the same server) to 2012 subscriber.

The object I want to replicate is an indexed view. The base tables exist only on the publisher.

The replication fails due to the following error:

Unable to replicate a view or function because the referenced objects or columns are not present on the Subscriber

It is true that the view doesn't exist in the subscription database. How can i create it without the base tables?

Best Answer

The clue to this is in the error, which is telling you that it can't create the view on the subscriber, because the subscriber is missing tables and/or columns that the view relies on.

You can't create the view without the base tables, so make sure you replicate the tables and/or columns involved in the view to the subscriber too, and then the view itself can be replicated.