Nonmaterialized computed columns and invalid values

The expressions for nonmaterialized computed columns are evaluated only at query time, and not during DML operations. This may lead to query problems if the formula used to create the expression is not validated before the computed column is created.

In this example, the computed column b is not evaluated until it is queried, so the domain error does not occur until the select statement runs (the error is particularly unpredictable if the select statement is embedded in a trigger):

create table t (a int, b compute sqrt(a)) 
go 
insert t values (2) 
insert t values (-1) 
insert t values (3) 
go 
select * from t 
go
1> select * from t
2> go
a b
----------- --------------------
2   1.414214
Domain error occurred.