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

Отвечено Unable to replicate a view or function because the referenced objects or columns are not present on the Subscriber

  • Wednesday, November 14, 2012 12:50 PM
     
      Has Code

    Hi,

    We are using merge pull replication with SQL Server 2008 r2.

    We added some views long time after the publication was created. (Not nested views, only table dependencies)

    ex: 

    create view VW_Empleados as
    select Empleado.ID_Cliente,Numero_Empleado,cliente.Nombre,Cliente_Retail.Apellido,Cliente.Email,
    Cliente.Notas,Telefono1,Telefono2,Cliente_Retail.Celular,Fax,ID_Empresa,Categoria_Cliente_Retail.Nombre Categoria_Cliente,
    Cliente_Retail.Documento_Identidad,Estado_Civil,Fecha_Nacimiento,Sexo,
    Empleado_Habilitado,Tipo_Empleado.Nombre TipoEmpleado
    from Empleado
    inner join Cliente on Cliente.ID_Cliente=Empleado.ID_Cliente
    inner join Cliente_Retail on Cliente_Retail.ID_Cliente=Empleado.ID_Cliente
    left outer join Tipo_Empleado on Tipo_Empleado.ID_Tipo_Empleado= Empleado.ID_Tipo_Empleado
    left outer join Categoria_Cliente_Retail on Categoria_Cliente_Retail.ID_Categoria_Cliente_Retail= Cliente.ID_Categoria_Cliente
    GO

    exec sp_addmergearticle @publication = 'IPoint_Pub', @article = N'VW_Empleados', @source_owner = N'dbo', @source_object = N'VW_Empleados',  @type = N'view schema only', @description = null, @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x0000000008000001, @destination_owner = N'dbo', @destination_object = N'VW_Empleados', @force_invalidate_snapshot=1

    Now, when initializing new subscribers we get:

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

    The error mentions the missing table "Cliente".

    Manually creating the missing tables solves the issue, but this is not an option for us because of the number of subsribers.

    This is only happening with new views we added.

    We have run exec sp_refreshview VW_Empleados 

    and then regenerated the snapshot but we get the same error.

    I am almost sure the the views were not created using dynamic SQL. exec (' ALTER View ...');

    Any help will be really appreciated.


    Best Regards, Daniel.

All Replies