sql-serverviewsql-server-2014transactional-replication

Why 'Views' need to be replicated?


Assuming View1 is based on Table A,B and C on Server1. Table A,B and C are replicated to Server2 using Transactional Replication. View1 is created on Server2.

ASK:
So will View1 on both the servers reflect the same data (discounting the replication delay)?
If they do, then what are the other reasons we replicate Views?
If the script of a View is changed at Publisher, do the changes reflect on the subscriber?


Solution

  • So will View1 on both the servers reflect the same data (discounting the replication delay)?

    Yes,the view in general queries the underlying tables

    If they do, then what are the other reasons we replicate Views?

    In simple terms ,if you want your view to be used by applications that access server2 you need to replicate view

    If the script of a View is changed at Publisher, do the changes reflect on the subscriber?

    Yes DDL Changes are supported..

    From MSDN.

    Replication supports a wide range of schema changes to published objects. When you make any of the following schema changes on the appropriate published object at a Microsoft SQL Server Publisher, that change is propagated by default to all SQL Server Subscribers:

    ALTER TABLE
    ALTER VIEW
    ALTER PROCEDURE
    ALTER FUNCTION
    ALTER TRIGGER
    ALTER TRIGGER can be used only for data manipulation language [DML] triggers because data definition language [DDL] triggers cannot be replicated.