Creating Tables With Computed Columns

Take these into consideration when creating tables with computed columns.

  • computed_column_expression can reference only columns in the same table.

  • The deterministic property of computed_column_expression significantly affects data operations. See Deterministic Property in the Transact-SQL Users Guide.

  • Computed columns cannot have default values, and cannot be identity or timestamp columns.

  • You can specify nullability only for materialized computed columns. If you do not specify nullability, all computed columns are, by default, nullable. Virtual computed columns are always nullable.

  • Triggers and constraints, such as check, rule, unique, primary key, or foreign key) support only materialized computed columns. You cannot use them with virtual computed columns.

  • If a user-defined function in a computed column definition is dropped or becomes invalid, any computed column operations that call that function fail.