0

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?

TheGameiswar
  • 27,855
  • 8
  • 56
  • 94
Alok Singh
  • 174
  • 3
  • 15

1 Answers1

0

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.

Community
  • 1
  • 1
TheGameiswar
  • 27,855
  • 8
  • 56
  • 94
  • 1
    Remember that "a `VIEW` is a *definition."* Therefore, when you "replicate the view," you are replicating *that definition,* not the data that the view appears to contain when you open it. You're ensuring that both servers will be executing the same SQL *(on their respective machines ...)* when either of them opens that view. – Mike Robinson Jul 22 '16 at 16:33
  • 1
    ... and the reason why "DDL triggers cannot be replicated" is because we don't want them to *go off!* – Mike Robinson Jul 22 '16 at 16:35
  • @MikeRobinson:Yes Mike that's correct. user stated he will be replicating the tables involved too. – TheGameiswar Jul 22 '16 at 16:35
  • Hello Gameiswar, Even if my applications need to access that view on server2, do I need to replicate that view using Transactional replication? Or I can just simply create the view at both ends and do not replicate it using T-rep? – Alok Singh Jul 22 '16 at 17:15
  • you should replicate it like other objects,not by creating it manually – TheGameiswar Jul 22 '16 at 17:38