-
New Toy: Computed Columns
-
I was doing a bit of prototyping over the weekend when I discovered
this nifty little feature. The SQL BOL for CREATE TABLE give this
option:
CREATE TABLE
[ database_name.[ owner ] .
| owner. ] table_name
( { <
column_definition >
| column_name AS
computed_column_expression
| < table_constraint > ::= [
CONSTRAINT constraint_name ] }
| [ { PRIMARY KEY | UNIQUE } [ ,...n ]
)
"....The expression can be a noncomputed column name, constant, function, variable,
and any combination of these connected by one or more operators. The expression
cannot be a subquery....."
Even in itself I found this very useful, and I easily overcame the
exclusion of subqueries by using a User Defined Funtion, which is
allowed.