SQL Server Replication Issues with Computed Columns

09 February 2022 | Viewed 1253 times

What is the Replication in SQL Server?

Replication is a technology for copying and distributing data and database objects from one database to another and then synchronizing databases to maintain consistency and integrity of the data. It is like real-time streaming data.

What is a Computed Column?

A computed column is a virtual column that is not physically stored in the table, unless the column is marked PERSISTED. A computed column expression can use data from other columns to calculate a value for the column to which it belongs.

Replication will fail for computed columns, because replication is trying to insert/update data for column, but it not allowed, as it is going to calculate based on expression defined in it. To fix this issue there are few options like -

1. Exclude Computed column from replication, so that you can compute it in Replication database. (or)
2. Make computed column as regular column (remove computed expression) in Replication database, and then replicate. (or)
3. Make kind property be equal to "PersistantReadOnly" for that Computed column in Replication database.


PreviousNext