We have replication setup on a database and is working fine.
Now we want to update the database on publisher. So using installer we updated the database but we are getting errors like cannot update table as table is in use.
So how can we update the database which is part of replication?
DML changes (insert, update, delete) will work as expected and replicate to subscribers. By default schema changes (DDL) will be propagated to subscribers on synchronization, publication property #replicate_ddl must be set to true. There are some exceptions which can be found in Making Schema Changes on Publication Databases.
Related
SQL Server 2012, 2014, 2016 transactional replication
Publication is created. (copy Foreign Keys is false, the default)
Subscription is created.
Snapshot and sync.
Turn off synchronization.
Upgrade the publication database.
Upgrade the subscriber database for tables affected by modified views.
Set the snapshot to only gather information for changes.
Restart sync.
There is now an error at the subscriber because the two new columns exist and the snapshot is trying to create them but with foreign keys.
Typically it hasn't cared but now it seems to because of the FK creation it wants to do. If I manually delete the two new columns the sync will now create them again but with FKs.
The same operation happens for other new fields but we've never run into this issue before.
Looking to understand why FKs are being sent and if there is a workaround or setting.
I have deployed 1 subscriber and 1 publisher server in merge replication configuration of SQL Server. I added a table along with a trigger on that table on publisher and want to replicate that table and trigger on subscriber. I have set 'replicate schema changes' and 'copy user triggers' to true but still the trigger is not replicated on subscriber.
How can I solve the problem?
I had a similar problem with merge replication. Despite anything I tried, new schema changes at Publisher were not applied at Subscriber even with Replicate schema changes set to true. In my case it were new columns not propagated to Subscriber even though they were explicitly checked at Publisher to be replicated, instead the following error was returned during sync:
Invalid column name 'new_col_name'. (Source: MSSQLServer, Error number: 207)
I ended up removing merge subscription, adding the new columns at Subscriber and then recreating the subscription. The same may be done to triggers.
Note, after removing and recreating Subscription you may need to re-initialize it which will replace all data in Subscriber's articles. If you want to preserve existing subscriber objects/data make sure to set the article property Action if name is in use to Keep existing object unchanged, see the image below:
HTH
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?
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.
I don't have much experience on SQL replication(SQL Server 2014). My client have a replication process which was created by his previous contractor. It worked well and suddenly it stopped replicating DDL statements couple of days ago. We have not done any change related to replication. When I checked data, subscriber has received up to date data. Only DDL statements have the problem. It uses transactional replication.
When I searched on web it says that the "Replicate schema changes" option need to set as true on Publication Properties.In my case it was already set to true.
Is there anyway for me to fix this and again have DDL statements to replicate as earlier?
Thank you
SQL Server Replication does support schema changes, but not all of them. In your case, CREATE PROCEDURE is not a supported schema change. Why? It's not an article yet, and not marked for replication, thus it cannot be replicated - replication has no way of knowing whether or not you would want that object replicated.
However, if you create the stored proc, then create an article for it, then issue an ALTER PROCEDURE, you will see the change replicated.
Please see article Make Schema Changes on Publication Databases:
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 TABLE SET LOCK ESCALATION should not be used if schema change replication is enabled and a topology includes SQL Server 2005 or SQL Server Compact 3.5 Subscribers.
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.
Please ensure you read the whole article, to be fully aware of what can be replicated, and under what circumstances.
What is the optimal way to update a schema on a publishing database that is push-replicated is SQL Server (2012).
Currently we disable replication, update the schema, re-enable replication and run a new snapshot.
As the database grows this strategy will become problematic as the snapshot will get bigger which will make deployments take longer over time.
Is there a way to do this without a new snapshot?
Schema changes can be made using ALTER syntax at the publisher. By default the schema change will be propagated to subscribers automatically, publication property #replicate_ddl must be set to true. There are considerations to make depending on the type of schema change and the publication type. This is covered in Make Schema Changes on Publication Databases and Replicate Schema Changes.