Daily Archives: Oct 1, 2014


What is Computed Column in sql server 4

Computed column is a virtual column in sql server, which is not stored physically in the table. It’s data is not materialized in the database and gets calculated during query execution on that column.

It takes it’s value from an expression and that expression can contain other columns to calculate a new value for the computed column.

Can it persist physically in the belonging table?

Yes, and to make it persist physically in table, just mark it as PERSISTED. By default it does not persist physically. In this case the data will be materialized in the table and will not be computed during query execution.

Without physical persistence:

With physical persistence:

Limitations:

  1. We can not target this column during insert and update.
  2. Default, Foreign key or NOT NULL constraints can not be applied to this column until it’s marked as PERSISTED.

Benefits:

  1. Readability : In case of some complex calculation
More